This program demonstrates the concept of inheritance in C++. It defines three classes: A, B, and C. Class A is the base class, and classes B and C are derived from class A. The program creates an object of class C, and when the object is created, the constructor of class A is called first, followed by the constructor of class C.
Here is a brief explanation of what happens when the program is executed:
#include<iostream> using namespace std; class A { public: A() { cout<<"Constructor of A class"<<endl; } }; class B: public A { public: B() { cout<<"Constructor of B class"<<endl; } }; class C: public A { public: C() { cout<<"Constructor of C class"<<endl; } }; int main() { C obj; return 0; }To download raw file Click Here
Constructor of A class Constructor of C class
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions