10.5 A MULTIPATH INHERITANCE

In a two-level inheritance, it is possible that a child will have two parent classes. However, the two parent classes may be derived from a single grandparent class. This situation is shown in Figure 10.6.

In Figure 10.6, a class named Instructor derives properties from two classes named Faculty and Lab staff. These classes, in turn derive properties from a single class named Employee. It implies that there will be two copies of class Employee in Instructor class. A grandparent class may contain data members such as name and salary. Two names are fine but what about two salaries. What if you are an employer and not an employee! (Are you ready to pay double amount for the same work?)

We have studied a rule that when ...

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.