   Classes in classes
  When I write this code in, where the 'NEURALNET' class has been defined, and has a ctor that takes 4 integer arguments, it gives me an error 'syntax error: constant' for the line NEURALNET ANN...but when I take it out of the TANK class, it works fine.  Also when I take out all the arguments from it, it works, but I don't know how it initializes the class seeing as it doesnt have the necessary data.class TANK{protected:NEURALNET ANN(6, 2, 1, 5);// in (pos, angle, tarangle, tardist), out(turn left, turn right), 1 hidden, 5/hiddenbool targeted;public:float position[2];float angle;void Target();};I have a feeling this is something really retarded, which is why i posted it in this section of gamedev :P (just kidding), but any help would be appreciated.   
  try just NEURALNET ANN; in thereand do the (6, 2, 1, 5) stuff in the constructor initializer list   ;  whats the constructor initializer list?   ;  [edit]In case Since[/edit] you don't know what a constructor initializer list looks like, it'd be something like this://TANK.Hclass TANK{protected:NEURALNET ANN;// in (pos, angle, tarangle, tardist), out(turn left, turn right), 1 hidden, 5/hiddenbool targeted;public:   TANK(); //Constructor declarationfloat position[2];float angle;void Target();};//TANK.CPPTANK::TANK() : ANN(6, 2, 1, 5), angle(0.0f) // <-- Initializer List{  //Whatever other initializations};  That would be the way to go.In a class declaration, you can't actually run any code, including constructors and initializations.For isntance, try putting "int foo=3;" into a class declaration. It won't compile. You can do all of your initializations in your class constructor like this.TANK::TANK() : ANN(6, 2, 1, 5){}That's to assure that the ANN object is not initialized until just before the TANK object is initialized.Edit: I'm stupid.   ;class C{    int value;    float f;public:    C(float f) : value(3), f(f) {}};If you define your constructor, the initialiser liste is everything between the ':' and the '{', so here it is value(3).You just list all members and put their new value in parantheses.;  You can't initialize a member as part of the class declaration.There are two possible things you might be wanting to do that I can think of:1) Make every TANK use the same NEURALNET object:class TANK{protected:static NEURALNET ANN; // <-- 'static' basically means 'shared' herebool targeted;public:float position[2];float angle;void Target();};TANK::ANN = NEURALNET(6,2,1,5);2) Make every TANK have its own NEURALNET, but always initialize it the same way upon TANK construction:class TANK{protected:NEURALNET ANN;bool targeted;public:float position[2];float angle;void Target();};TANK::TANK() : ANN(6,2,1,5) {  // no-argument constructor, which sets up the NEURALNET using  // an initializer list. This is preferable to setting it up  // inside the constructor body for a couple of good technical  // reasons, which others are better qualified to explain.  // do other setup stuff here.};Quote:Original post by pi_equals_3TANK::TANK() : ANN(6, 2, 1, 5){}That's to assure that the ANN object is not initialized before the TANK object is initialized.But the ANN object is initialized before the TANK object.   ;Quote:Original post by nmiQuote:Original post by pi_equals_3TANK::TANK() : ANN(6, 2, 1, 5){}That's to assure that the ANN object is not initialized before the TANK object is initialized.But the ANN object is initialized before the TANK object.Aww, fine, but they're initialized at around the same time.   ;Quote:Original post by pi_equals_3Aww, fine, but they're initialized at around the same time.Actually they are not. The initializer list always comes first. Before the code of the constructor is executed, all base classes and members of the instance have to be initialized. To control this process, only the initializer list may be used.