For multiple inheritance, write a program to show the invocation of constructor and destructor.
CODING:
#include<iostream.h>
#include<conio.h>
class A
{
public:
A()
{
cout<<"\nCONSTRUCTOR CLASS A";
}
~A()
{
cout<<"\nDESTRUCTOR CLASS A";
}
};
class B
{
public:
B()
{
cout<<"\nCONSTRUCTOR CLASS B";
}
~B()
{
cout<<"\nDESTRUCTOR CLASS B";
}
};
class C:public A,B
{
public:
C()
{
cout<<"\nCONSTRUCTOR CLASS C";
}
~C()
{
cout<<"\nDESTRUCTOR CLASS C";
}
};
void main()
{
clrscr();
C c;
getch();
}
CODING:
#include<iostream.h>
#include<conio.h>
class A
{
public:
A()
{
cout<<"\nCONSTRUCTOR CLASS A";
}
~A()
{
cout<<"\nDESTRUCTOR CLASS A";
}
};
class B
{
public:
B()
{
cout<<"\nCONSTRUCTOR CLASS B";
}
~B()
{
cout<<"\nDESTRUCTOR CLASS B";
}
};
class C:public A,B
{
public:
C()
{
cout<<"\nCONSTRUCTOR CLASS C";
}
~C()
{
cout<<"\nDESTRUCTOR CLASS C";
}
};
void main()
{
clrscr();
C c;
getch();
}
Comments
Post a Comment