Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

What Is Shared (Repeated or virtual) Inheritance?

0
10 Posted

What Is Shared (Repeated or virtual) Inheritance?

0

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.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.