If other future classes are obtained from foo
more than one way, then the most derived class will contain only one virtual base class bar
and kung
:
struct A : foo { }; struct B : foo { }; class Gizmo : public A, public B { };
An object of type Gizmo
has a unique base subobject of type bar
and ditto for kung
, and not two different for each derivation path.
Note that if a class has only pure virtual functions, and not non-static members and only base classes of the same nature, then there is no practical difference between virtual and non-virtual inheritance, since classes are empty. Other, smaller languages call such classes “interfaces”, which means that they should be inherited from them, even if such languages do not support multiple inheritance for common classes.
source share