Lecture 5 - Slide 20 : 40
Shared base class: Virtual bases

It is also possible for B and C to to share their A parts in a D-object - virtual bases

To see this image you must download and install the SVG plugin from Adobe.In Firefox please consultthis page.

Per default you get replicated base classes in C++

Illustration of shared, virtual, base class A.
Program output.

Every base class of a given name that is specified to be virtual will be represented by a single object of that class, (§21.3.5, 4ed)

A constructor of a virtual base must be called exactly once - see the exercise for additional details

Go to exercise
Ignoring constructors in virtual base class
Ignoring constructor in virtual base class.
Forcing use of a constructor in a virtual base class.