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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access