Example:3
#include<iostream>
#include<conio.h>
#include<string.h>
using namespace std;
class A
{
public:
A()
{
cout<<"Constructor of class A"<<endl;
}
};
class B
{
A a1;
public:
B()
{
cout<<"Constructor of class B"<<endl;
}
};
class C
{
A a1,a2;
B b1;
public:
C()
{
cout<<"Constructor of class C"<<endl;
}
};
int main()
{
C a1;//1
B b1;//2
A c1;//3
return(0);
}
/* Output */ Constructor of class A Constructor of class A Constructor of class A Constructor of class B Constructor of class C Constructor of class A Constructor of class B Constructor of class A




