Pure virtual
Destructors
Pure virtual destructors are legal in C++.Also pure virtual
destructors must be defined, which is against the pure virtual behavior.
The only difference between virtual and pure virtual
destructors is, that pure virtual destructors will make its base class Abstract,
hence you cannot create object of that class.
There is no requirement of implementing pure virtual
destructors in the derived classes.
class Base
{
public:
Virtual ~Base()=0; // Pure Virtual Destructor
};
Base ::~Base()
{
cout<<”Base Destructors”; //definition of Pure virtual Destructor
}
class Dervied :public Base
{
public:
~Derived()
{
cout<<”Derived destructor”;
}
0 comments:
Post a Comment