Page 182 - DCAP404 _Object Oriented Programming
P. 182
Unit 9: Inheritance
9.2.2 Multilevel Inheritance Notes
When the inheritance is such that, the class A serves as a base class for a derived class B which in
turn serves as a base class for the derived class C. This type of inheritance is called ‘MULTILEVEL
INHERITANCE’. The class B is known as the ‘INTERMEDIATE BASE CLASS’ since it provides a
link for the inheritance between A and C. The chain ABC is called ‘INHERITANCE*PATH’ for e.g.
Base class
A
Inheritance path B Intermediate
base class
Derived class
C
The declaration for the same would be:
Class A
{
//body
}
Class B : public A
{
//body
}
Class C : public B
{
//body
}
This declaration will form the different levels of inheritance.
Task In your words write down the definition of Intermediate Base Class.
Following program exhibits the multilevel inheritance.
# include < iostream.h>
# include < conio.h>
class worker //Base class declaration
{
LOVELY PROFESSIONAL UNIVERSITY 175