Hi,
I have to initiates a object to a variable in the private section of my class deceleration. The problem is that I can not add a try catch to it in this way. I Don't think I am explaining things to well (it's been a long day) so here is my current relevant code.
class Controller {
private:
PlayerCc::PlayerClient robot ;// = newPlayerCc::PlayerClient("localhost");
PlayerCc::RangerProxy rp;//(&robot,0);
PlayerCc::Position2dProxy pp;
Nunet net;
public:
Controller(vector<float> cromo);
};
inline Controller::Controller(vector<float> cromo)
: robot("localhost"),
rp(&robot,0),
pp(&robot,0)
{
//robot = new PlayerCc::PlayerClient("localhost");
getSonar();
net.init(16,8,2);
net.setWeights(cromo);
}
The line I am concerned with is "PlayerCc::PlayerClient robot;" as I have to initialize it during the setup of the constructor (not sure of the technical term) such as ":robot("localhost")," but currently this throws out a error and i would like to catch it to see what it says. I can't see how to attach a try/catch block to that piece of code though.
I should tell you about the few things I have tried. i have tried changing the line "PlayerCc::PlayerClient robot;" to "PlayerCc::PlayerClient robot = new PlayerCc::PlayerClient("localhost");" with no luck. I have also tried setting "PlayerCc::PlayerClient robot = NULL;" but that was not allowed I have also tried not setting it at all but that also failed.
Sorry if this is incomprehensible. If you would like a rewrite when my brain is working just tell me what you don't understand.
Thanks
Alex