A question about the philosophy of C++.
I have a class of robots. These robots sometime bump into each other. So each robot would like to know where the other is. Also, each robot has a laser that can "shoot" the other robots.
The robot class is defined like this:
laser * m_plaser;
So this allows the standard laser and all of its child variations to be
Now, the laser needs to know where the robot is so it can shoot it.
Now here is my problem, the robot has a laser as part of it, and the laser needs to take a robot as an input to find out if it can hit it. And a cicular reference thing happens.
So how can I get around this.
Somebody mentioned to me that I need to do a Manager/Managed item pattern. ie give each robot a reference to an enviornment, When a robot wants to shoot its laser, it asks the envionrment and the enviornment works out if it hit.
I've tried nutting out the environment thing as well, but keep on running into similar problem.
So any suggestions would be appreciated. If you can think of a completely different way to atack this, that would be cool as well.
P.S. this seems like a fairly basic thing in C++, and I think i've missed something easy. So I think it is an easy quesion, but feel free to change its value