10.6 VIRTUAL BASE CLASS

The concept of virtual base class is very interesting. Let us take an example from an Engineering College. There are Laboratory staff to take care of upkeep of laboratories and Faculty to teach various subjects. There are Instructors who give instructions in the laboratory and therefore have common feature of faculty and lab staff. All these categories are college employees. We define a base class Employee and there from derive the classes Faculty, Lab staff and Instructor. This situation is depicted in Figure 10.6.

 

images

 

Figure 10.6 Multiple inheritance

Let us convert these diagrams into class declarations. If we try to ...

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.