What is the purpose of pure virtual destructor?

Viewed 3519

Possible Duplicates:
Under what circumstances is it advantageous to give an implementation of a pure virtual function?
Why do we need a pure virtual destructor in C++?

Compiler doesn't force the Child class to implement a destructor when its Base has pure virtual destructor.

struct Base
{
  virtual void foo () = 0;
  virtual ~Base() = 0;
};
Base::~Base() {} // necessary

struct Child : Base
{
  void foo() {}
  //ok! no destructor needed to create objects of 'Child'
};

Funny part is that; compiler rather forces the Base to define a destructor body. Which is understood. (Demo for reference)

Then what is the purpose of having pure virtual destructor in Base class ? (Is it just to disallow Base creating objects?)

4 Answers
Related