Professional Documents
Culture Documents
};
class B:public A
{ int b1,b2;
public:
B(int z): A(z)
{
};
void main()
{
clrscr();
cout<<"*******************************************************************\n";
cout<<"How parameters are passed to constructor Functions in case of\n";
cout<<"MULTI-LEVEL INHERITANCE :\n"
<<" class A BASE OF B\n"
<<" ^\n"
<<" |\n"
<<" class B DERIVED FROM A & BASE OF C\n"
<<" ^\n"
<<" |\n"
<<" class C\n";
cout<<"*******************************************************************\n\n\n
";
cout <<"Object of class C is going to be created ......\n"
<<"Press a key to do so.....\n";
getch();
C objC(50,100);
objC.showC();
cout<<"Now Object of Class C is going to be destroyed...\n"
<<"Check the Order in which destructors are going to be invoked...\n\n";
getch();
}
class A BASE OF B
^
|
class B DERIVED FROM A & BASE OF C
^
|
class C DERIVED FROM B
*******************************************************************
Object of class C is going to be created in next line......
Press a key to do so.....
Constructor of Class A invoked
Constructor of class B invoked
Constructor of Class C invoked
a1=50
b1=5 b2=7
c1=100
Now Object of Class C is going to be destroyed...
Check the Order in which destructors are going to be invoked...
*/