Multiple Level of Inheritance


  • Classes can be derived from derived classes also. The following segment illustrates this.
    class A
    { };
    class B: public A 	//First level of inheritance
    { };
    class C: public B 	//Second level of inheritance
    { };
    
  • Hence B is derived from A and C is derived from B. Now, you have two levels of inheritance.
    Click here for Example
  • In the above example, the student class is the base class.
  • The marks class is derived from student and forms the first level of inheritance.
  • The report class is derived from marks class.
  • This forms the second level of inheritance as the report class is derived from marks, which is derived from student.
  • The data member mks of marks class is specified as protected because the total is calculated in the reports class.


Containership<< Previous

Next >> Multiple Inheritance

Our aim is to provide information to the knowledge seekers. 


comments powered by Disqus




Footer1