I have an initialization list:
For some reason I get a warning "c will be initialized after b". Why?Code:class foo : a(), b(), c() {
Printable View
I have an initialization list:
For some reason I get a warning "c will be initialized after b". Why?Code:class foo : a(), b(), c() {
That order probably differs from the order in which they are declared in the class and which determines the real order how class members are going to be initialized.
This could lead to errors if you use members of the class to initialize other members.
Code:struct X
{
int b;
int a;
X(int n): a(n), b(a) {} //a will be initialized after b which uses a's value!
};
Just missed this one, I take it?
http://cboard.cprogramming.com/cplus...t-defined.html