What Is Shared (Repeated or virtual) Inheritance?
Multiple Inheritance allows the possibility for a class to appear as a parent more than once in a class graph (repeated inheritance), and there is then a potential to share that class. Only one instance of the class will then appear in the graph (as is always the case in CLOS, because all *members* with the same name will be shared (receive a single slot) with the greatest common subtype as its type). C++ provides an alternative, where only parents specified as (virtual base classes (p 396)) are shared within the same class lattice, allowing both shared and non-shared occurrences of a parent to coexist. All “features” in Eiffel (C++ members) of a repeated parent that are not to be shared must be renamed “along an inheritance path”, else they are shared by default. This allows a finer granularity of control and consistent name resolution but requires more work for parents with many features. The following example shows the effective structure for virtual inheritance.