Jump to content

C++ Programming

From Wikibooks, open books for an open world
Multiple inheritance
[edit | edit source]

Multiple inheritance is the process by which one class can inherit the properties of two or more classes (variously known as its base classes, parent classes, ancestor classes, or super-classes).

Note:
In some similar languages, multiple inheritance is restricted in various ways to keep the language simple, such as by allowing inheritance from only one real class and a number of "interfaces", or by completely disallowing multiple inheritance. C++ places the full power of multiple inheritance in the hands of programmers, but it is needed only rarely, and (as with most techniques) can complicate code if used inappropriately. Because of C++'s approach to multiple inheritance, C++ has no need of separate language facilities for special language constructs that are usually called "interfaces", "traits" or "mixins" in other Object-Oriented languages, because C++'s classes themselves already provide this functionality.

This is shown in more detail in the C++ Classes Inheritance Section of the book.