10.2 HIERARCHICAL INHERITANCE

Hierarchical inheritance signifies one base and many derived classes. This is a very common form of inheritance in practice. In our opinion, it is not different from single inheritance. Consider that “A” is a base class and “B”, ”C” and “D” are derived classes. This is shown in Figure 10.3. The pairs (A and B), (A and C) and (A and D) can be considered as examples of single inheritance. In addition, there is no interaction between different derived classes. Rules for defining such classes and defining constructors for derived classes are absolutely same as single inheritance.

We will see this type of inheritance again in Chapter 13 “Polymorphism”.

 

 

Figure 10.3 Hierarchical inheritance

Get Object Oriented Programming with C++, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.