Multi level inheritance in C++ OOP, Example of multi level inheritance, Syntax of multi level inheritance, Basic program of multi level inheritance
In this tutorial we will learn about the followings;
- Multilevel inheritance in C++ OOP
- Example of multi-level inheritance in C++ OOP
- The syntax of multi-level inheritance in C++ OOP
- The basic program of multi-level inheritance in C++ OOP
What is Multi-level inheritance?
Derived class can be derived from another derived class. A child class can be the parent of another class.
Give an example of multilevel inheritance?
Class C is a child of class B and class B is child class of class A.
What is the syntax of multilevel inheritance?
Statements of Class A
Class B: public class A
Statements of Class b
Class C: public class B
Statements of Class C
Basic Program of multi-level inheritance
using namespace std;
class child2 : public child1
Here in this example there is multi level inheritance because
- Declaration of variable n1 is inherited from sum to child1
- Declaration of Variable n2 is inherited from chil1 to child2
- Child2 now uses one variable of its first parent and one variable of its grandfather.
So, this is a better example of multilevel inheritance.