class X { }class M{ public: M(X* x) {}}class Y{ private: M m; X* x; public: Y(X* nx): x(nx), m(x) {}}
The above code raises an exception when attempting to create a new class Y. The order of attributes is M, X*. In the constructor, x is initialised with nx, then m is initialised with the class attribute x.. this is not the case. Initialisation order is done in order of specification in code,
so the constructor actually executes like so:
Y(X* nx): m(x), x(nx) {}
As specified in C++ standard.
VC++ 2003 does not give any warnings or errors during compilation about using attributes before they've been assigned a value, it'd be helpful if it did :(