| January 01, 2007 08:45:58 |
#8 |
| muralidhar |
Member Since: Visitor Total Comments: N/A |
RE: Why we use Virtual Destructor? |
Hello all.
This is the simple example code..
#include <iostream> using namespace std; class Base { public: Base(){ cout<<"Constructor: Base"<<endl;} virtual ~Base(){ cout<<"Destructor : Base"<<endl;} }; class Derived: public Base { //Doing a lot of jobs by extending the functionality public: Derived(){ cout<<"Constructor: Derived"<<endl;} ~Derived(){ cout<<"Destructor : Derived"<<endl;} }; void main() { Base *Var = new Derived(); delete Var; }
|
| |