if I have these classes :
class A
{
int x,y;
public:
A(const int &x,const int &y):x(x),y(y){}
};
class B:public A
{
int z;
public :
B(const int &x,const int &y,const int &thez):z(thez),A(x+z,y+z)
};
I want to initialize z
in class B before calling A's constructor but as I discovered from debug A's constructor always get called first no matter where it's put.
The real goal of this is to calculate rotational inertia of a Player class(the Player found in foosball) that is composed of three cubes( head, body, and legs), the three cubes are initialized in the Player constructor and Player inertia is initialized in Body's constructor(Body is the parent of Player).
My problem is that inertia of the Player depends on the inertias of the cubes, I calculate them and I want to sum them and call parent on it but I can't sum them without initializing the cubes(they're nothing before initializing).
So how to do this ?
PS
I know I can just put the relations and sum, well yes but it's veeeery long, the constructor will get ugly easily if I did that, I'm considering this as last resort only.