2:23 PM
Program for concept of virtual destructor in c++

Develop a program for concept of virtual destructor in c++  (in dev c++)

 

#include<iostream>

#include<conio.h>

using namespace std;
class base{
public:
base()
{
cout<<"constructing base"<<endl;
}
 ~base()
{
cout<<"destructing base"<<endl;
}
};
class derive:public base
{
public:
derive()
{
cout<<"derive class constructing"<<endl;
}
virtual ~derive()
{
cout<<"derive class destructing"<<endl;
}
};
main()
{
base *b1=new derive;
delete b1;
getch();
}
 
 
Output:
 
constructing base
derive class constructing
derive class destructing
 
Views: 133 | Added by: vijoriya | Tags: Program for concept of virtual dest | Rating: 0.0/0
Total comments: 0
avatar