Hybrid Inheritance With Example

Explain Hybrid Inheritance With Example







Hybrid inheritance:-   

The mechanism of deriving a new class from more than one form for inheritance is called hybrid inheritance.  In some situations we need to apply 2 or more types of inheritances in the design of our program. 

For example consider the following hierarchy of classes.
                       

1)    It’s a combination of single-level, multi-level, multiple and hybrid Ineritance.
2)    Here the resultant (last or grand-child) Child class in the structure can acquire duplicate copies from the grand parent class.
1)     In situations where the resultant child class can acquire duplicate copies of the grand parent class then grand parent class used during inheritance is accompanied with “ virtual “ keyword, to avoid duplicity in the grand child class.

Labels: