Tested in the following order:
First, the constructor of the static member is executed, and if the static member is declared in the class definition but not implemented, it is not constructed. It must be initialized before its constructor is executed.
The constructors of any virtual inheritance base class are constructed in the order in which they are inherited (not in the order in which the list is initialized)
Iii. constructors of any non-virtual inherited base class are constructed in the order in which they are inherited (not in the order in which the list is initialized)
The constructors of any member objects are constructed in the order in which they are declared
Five, class own constructors
The test procedure is as follows:[CPP] View plain copy #include <iostream> #include <string> using namespace std; //abstract class a class a { public : a () { cout<< "constructor for abstract Class A" <<endl; } //pure virtual function fun virtual void fun1 () = 0; }; //abstract class b class b { public: b () { cout<< "constructor for abstract class B" <<endl; } //pure virtual function fun virtual void fun2 () = 0; }; //General c class c { public: c () { cout<< "Class C constructor" <<endl; } }; //Common class d class d { public: d () { cout<< "Class D constructor" <<endl; } }; //Common type c class e { public: e () { cout<< "Class E constructor" <<endl; } };   General class d class f { public: f () { cout<< " Constructor for Class F "<<endl; } }; //Common class d class g { public: g () { cout<< "Class G constructor" << endl; } }; /General class d Class h { public: h () { cout<< "Constructor for Class H" <<endl; } }; //Common class d class m { public: m () { cout<< "Class M constructor" <<endl; } }; Class test: public a,public b,virtual public C,virtual public D,public E,public F { public: test (): B (), A (), D (), C (), F (), E () { cout<< "class Test constructor" <<endl; } void fun1 () { } void fun2 () { } private: G g; &nBsp static H h; static M m; }; h test::h; int main (int argc, char* argv[]) { Test test; return EXIT_SUCCESS; } result: class H constructor (Static member class, and initialized)
Constructor for Class C (Virtual inheritance base class)
Constructor for Class D
Constructor for abstract Class A (non-virtual inheritance base class)
Constructors for abstract class B
Constructor for Class E
Constructor for Class F
Constructor for Class G (normal member object construction)
Constructor for class test (derived class own constructor)