Having this struct:
struct Coordinates
{
int x;
int y;
Coordinates(int x_axis, int y_axis)
{
x = x_axis;
y = y_axis;
}
Coordinates()
{
std::cout << " CALL " << std::endl;
}
};
And having this class:
class Character
{
public:
bool canSpeak;
int hp;
float gold;
Coordinates position;
Character();
};
I want to understand one thing (I know that the class' members initialize in the order in which they are declared). So, if I would do this:
Character::Character() : position(25, 32), canSpeak(1), hp(position.y), gold(position.x)
{
std::cout << gold << " " << hp << std::endl;
}
Both hp and gold would contain garbage values but I would like to see the chronological axis in which this happens because before the curly brackets, all class members should be initialized (this means they do need to initialize between : and { , and if they initialize in the order in which appear, how can position.y and position.x be 'used'?
I was expecting the Coordinates::Coordinates() to be called before the Coordinates::Coordinates(int x_axis, int y_axis) in order for the compiler to be able to use position.x and position.y but this doesn't happened. So I don't understand what happens chronological.
