Lecture 5 - Slide 20 : 40 |
It is also possible for B and C to to share their A parts in a D-object - virtual bases
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
![]() | Ignoring constructor in virtual base class. |
![]() | Forcing use of a constructor in a virtual base class. |