#include<iostream>
using namespace std;
class Mahesh
{
public:
Mahesh(){
cout<<"Base Constructor is called at here"<<endl<<endl;
}
virtual ~ Mahesh()
{
cout<<"Base Destructor is called"<<endl<<endl;
}
};
class Purnima:public Mahesh
{
public:
Purnima()
{
cout<<"Derived class constructor"<<endl<<endl;
}
~Purnima(){
cout<<"Derived class Destructor"<<endl<<endl;
}
};
int main()
{
Mahesh *m1;
Purnima p1;
m1=&p1;
return 0;
}
My question is if I don't write keyword virtual
in front of destructor then above code works fine, then why virtual destructor?