You cannot see any difference in output, because the output will be the same in any of the following hiearchies of the class:
Hiearchy 1
class A {}; class B2 : virtual public A {}; class C2 : virtual public B2 {};
Hiearchy 2
class A {}; class B2 : public A {}; class C2 : virtual public B2 {};
Hiearchy 3
class A {}; class B2 : virtual public A {}; class C2 : public B2 {};
Hiearchy 3
class A {}; class B2 : public A {}; class C2 : public B2 {};
In all these cases, A::A() is executed first, then B2::B2() , and then C2::C2() .
The difference between the two is when it calls the A::A() call. Is it called from B2::B2() or C2::C2() ?
I am not 100% sure of the answer to Hiearchy 1 . I think B2::B2() should be called from C2::C2 , since B2 is the virtual base class of C A::A() must be called from B2:B2() , since A is the virtual base class of B2 . But I could be wrong in the exact order.
In Hierarchy 2 , A::A() will be called from B2::B2() . Since B2 is the base class of virtual C2 , B2::B2() is called from C2::C2() . Since A is a normal base class of B2 , A::A() is called from B2::B2() .
In Hierarchy 2 , A::A() will be called from C2::C2() . Since A is a virtual base class, A::A() is called from C2::C2() . B2::B2() is called after the completion of the call A::A() .
In Hierarchy 4 , A::A() will be called from B2::B2() . I think this case needs no explanation.
To clarify my doubts about Hiearchy 1 , I used the following program:
I got the following output:
Called from : C2::C2()
This confirms that @TC is indicated in his comment, which is different from what I expected. A::A() is called from C2::C2 , not from B2::B2 .