I am a freshman in C++, especially about object-oriented programming. And now I have a problem during my learning.
There is a class hierarchy following:
class Class{};
class Base:public Class{};
class Derived1:virtual public Base{};
class Derived2:virtual public Base{};
class MI:public Derived1,public Derived2{};
class Final:public MI,public Class{};
And now I want to know what the order of constructor for the definition of a Final class object is.
I draw a diagram:

structure of class inheritance http://hi.csdn.net/attachment/201203/16/2712336_1331902452BziD.jpg
I know Virtual base classes are always constructed prior to nonvirtual base classes regardless of where they appear in the inheritance hierarchy. What I am confused is that if constructor of class Class is before Base, and if constructor of Class is invoked twice. And why?
Can someone tell my the answer? The more detailed, the better.
The direct inheritance of
ClassbyFinalandBaseis notvirtual, so an instance ofFinalhas two base class subobjects of typeClass. The one that is the direct base ofBaseis constructed beforeBase, and the one that is the direct base ofFinalis constructed afterwards (in fact afterMI).The reason is that:
Applying (1) to
Finaltells us thatClassis constructed afterMI. Applying (2) several times tells us thatClassis constructed beforeBase, beforeDerived1andDerived2, beforeMI.