![]() |
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. Multilevel InheritanceDerivation 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. C++
Output
Base class A constructor Class B constructor Class C constructor Example 2: Below is the C++ program to implement multilevel inheritance. C++
Output
Sum is:11 Difference is:15 Product is:200 |
Reffered: https://www.geeksforgeeks.org
C++ |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 13 |