Constructor in Multilevel Inheritance in C++
Constructor is a class member function with the same name as the class. The main job of the constructor is to allocate memory for class objects. Constructor is automatically called when the object is created.
Derivation of a class from another derived class is called Multilevel Inheritance. Class A is the base class for the derived class B, which in turn serves as a base class for the derived class C. Class B provides a link for the inheritance between A and C and is known as an intermediate base class. The chain A, B, C is known as the inheritance path.
Constructor in Multilevel Inheritance
Example 1: Below is the C++ program to show the concept of constructor in multilevel Inheritance.
Base class A constructor Class B constructor Class C constructor
Example 2: Below is the C++ program to implement multilevel inheritance.
Sum is:11 Difference is:15 Product is:200
Please Login to comment...