![]() |
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. Multiple Inheritance: Multiple Inheritance is a feature of C++ where a class can derive from several(two or more) base classes. The constructors of inherited classes are called in the same order in which they are inherited. ![]() Multiple Inheritance Model Syntax of Multiple Inheritance: ![]() Syntax of Multiple Inheritance:
Example 1: Below is the C++ program to show the concept of Constructor in Multiple Inheritance. C++
Output
Constructor of the base class A2 Constructor of the base class A1 Constructor of the derived class S Time complexity: O(1) Example 2: Below is the C++ program to show the concept of Constructor in Multiple Inheritance. C++
Output
Difference is:8 Sum is:55 Product is:320 Time complexity: O(1) |
Reffered: https://www.geeksforgeeks.org
C++ |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 13 |