Multilevel inheritance

Definition:

 

The mechanism of deriving a new class from another derived class is called as multilevel inheritance. The class A serves as base class for derived class B which in turn serve as base class for the derived class C. The class B is known as intermediate base class since it provides link for inheritance between A and C. The chain ABC is known as inheritance path.

 

Example:

 

 

Example:

A derived class with multilevel inheritance are declared as follows

class A { ....... } // Base class
class B: public A { ....... } // B is derived from A
class C: public A { ....... } // C is derived from B

This process can be extend to any levels.

 

Assume that the test results of the student are stored in three classes classes student is base class stores roll no,test is the intermediate base class stores the mark obtained in the two subjects and the result is the derived classes inherit the details of mark obtained and the student roll no of the student through multilevel inheritance.

 

 

 

 

Inheritance types by s.kamatchi priyanka