write a program to demonstrate,how constructor and
deconstructor work under multilevel inheritance
Answer Posted / kunalsahu
#include<iostream.h>
#include<conio.h>
class a
{
//Data
public:
a()
{
cout<<"class A Constructor\n" ;
}
~a()
{
cout<<"class A Destructor"<<endl;
}
};
class b:public a
{
//Data
public:
b()
{
cout<<"class B Constructor"<<endl;
}
~b()
{
cout<<"class B Destructor"<<endl;
}
};
class c:public b
{
//Data
public:
c()
{
cout<<"class C Constructor"<<endl;
}
~c()
{
cout<<"class C Destructor"<<endl;
}
};
int main()
{ clrscr();
//c *pCObj;
//pCObj=new c();
c k;
getch();
return 0;
}
/*O/p:
class A Constructor
class B Constructor
class C Constructor
class C Destructor
class B Destructor
class A Destructor */
| Is This Answer Correct ? | 7 Yes | 0 No |
Post New Answer View All Answers
write a program to convert a decimal number in to its equivalent binary number?
Can we use stl in coding interviews?
How do you convert stl to steps?
When did c++ add stl?
What is stl in c++ with example?
What is a standard template library (stl)? What are the various types of stl containers?
What is a stl vector?
How do I convert a stl file?
What do stl stand for?
draw a flowchart that accepts two numbers and checks if the first is divisible by the second.
What two types of containers does the stl provide?
What does stl mean in slang?
Is string part of stl?
what is template and type convertion
Is stl part of c++ standard?