Inheritence and its types in object oriented programmings?

1 answer

Answer

1289957

2026-05-12 18:05

+ Follow

There are only two types of inheritance in object oriented programming:

Single inheritance: where a class inherits directly from just one base class.

Multiple inheritance: where a class inherits directly from two or more base classes.

Multi-level inheritance is often thought of as being a separate type of inheritance, however inheritance relates to a derived class and those that it directly inherits from. If a base class is itself a derived class (an intermediate class), then its base class or classes are simply indirect base classes of the derivative. But in isolation, the intermediate class either uses single or multiple inheritance, even if its base class or classes are also intermediates.

Virtual inheritance is also thought of as being a separate type, however virtual inheritance doesn't change the relationship between classes within the hierarchy. the only difference virtual inheritance makes is that the virtual base class or classes are constructed by the most-derived class within the current hierarchy, rather than by their most direct descendants. In this way, only one instance of each virtual base exists in the hierarchy, rather than multiple instance as would normally exist. The actual inheritance is still single or multiple, however.

ReportLike(0ShareFavorite

Related Questions

Copyright © 2026 eLLeNow.com All Rights Reserved.