10.4 HYBRID INHERITANCE

Hybrid inheritance is a combination of multiple inheritance and multilevel inheritance. A class is derived from two classes as in multiple inheritance. However, one of the parent classes is not a base class. It is a derived class. This is shown in Figure 10.5.

Let us assume class PlainTicket. It contains information like class (I or II) of travel, distance and fare. Consider a case of class SimpleTicket, a class derived from class PlainTicket. It has additional fields of say date, source and destination stations. Class PaxInfo stores the information of a passenger. Assume that railway issues separate reserved ticket to every passenger. Now class ReservedTicket is derived from PaxInfo and SimleTicket. It is an example of ...

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.