write a program to demonstrate,how constructor and
deconstructor work under multilevel inheritance

Answer Posted / archana

class a
{
//Data
public:
a(){cout<<"class A Constructor"<<endl}
~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()
{
c *pCObj;
pCObj = new c();
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 ?    8 Yes 9 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

i wanted to know about questions about c,c++ , which is required for placements.... im a fresher

1714


What are the symptoms of stl?

613


Can we use stl in coding interviews?

1294


What is a standard template library (stl)? What are the various types of stl containers?

680


Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL.

1985






What are the components of stl?

637


how to use C++?

2074


What is stl in oop?

695


What is a list in c++ stl?

703


Why should a c++ programmer be interested in stl?

651


Is string part of stl?

693


how can u do connectivity in c++ language? plz send me connectivity code in c++ ?

1908


How does an stl file work?

667


write a program to convert a decimal number in to its equivalent binary number?

2090


Who wrote stl?

692