F
francesco.orsenigo
In the code below, at instantiation of a "listC" object, the
constructors for attributes "a", "b", and "c" are called in sequence
from "a" to "c".
How much is this behaviour reliable?
Does the c++ specifics tell something about it?
What are the odds for the constructors to be called in a different
sequence, like "cba" or "bca" or whatever?
What if "a", "b" and "c" are not of the same class?
Thanks,
Francesco
#include <iostream>
class itemC { public:
int item;
itemC() { std::cout << "init object at " << (void*)this <<
std::endl; }
};
class listC { public:
itemC a;
itemC b;
itemC c;
};
int main()
{
listC list;
}
//EOF
constructors for attributes "a", "b", and "c" are called in sequence
from "a" to "c".
How much is this behaviour reliable?
Does the c++ specifics tell something about it?
What are the odds for the constructors to be called in a different
sequence, like "cba" or "bca" or whatever?
What if "a", "b" and "c" are not of the same class?
Thanks,
Francesco
#include <iostream>
class itemC { public:
int item;
itemC() { std::cout << "init object at " << (void*)this <<
std::endl; }
};
class listC { public:
itemC a;
itemC b;
itemC c;
};
int main()
{
listC list;
}
//EOF