//One of the beginner's traps in C++ is that the order of the constructor initialization list is irrelevant. As shown by this question, the order is dependent on the order of declaration of the class members. This decision was a result of the inconsistencies that could otherwise be introduced in the presence of multiple constructors with differing initialization lists (C++ Standard 12.6.2/5). //Do not miss the important secondary concept of initialization list scope illustrated by one of the wrong answers. // note also that this demonstrates that a const class attribute, can be intializeed from the class constructor list. #include #include using namespace std; class A { public: const string str; A( string& str) : str(str) { cout << "hello from A ctor" << endl; } A() : str( "default_A") { cout << "hello from A ctor" << endl; } }; class B { public: string str; B( string& str) : str(str) { cout << "hello from B ctor" << endl; } B() : str( "default_B") { cout << "hello from B ctor" << endl; } }; class C { public: string str; C( string& str) : str(str) { cout << "hello from C ctor" << endl; } C() : str( "default_C") { cout << "hello from C ctor" << endl; } }; class ABC { public: C d; A a; B b; C c; ABC( string& stra, string& strb, string& strc) //: b(stra), a(strb), c(strc) { } }; int main() { string fu("fu"), man("man"), chu("chu"); ABC abc( fu, man, chu); return 0; }