Pages

22 Apr 2012

Pure Virtual Destructor

Pure Virtual Destructor is an interesting concept available in C++, consider the following example


class Base
{
public:
AbstractBase(){}
void print(){}
virtual ~AbstractBase() =0{}
};


class Derived : Base
{
public:
Derived(){}
};


Interesting part is we can make class Base an abstract class with no pure virtual functions other than destructor. And derived class need not implement the pure virtual function of base as well.
Only this we need to make sure is pure virtual destructor always needs an implementation.

No comments:

Post a Comment