Why pure virtual destructor should have body.

Why we should provide body to pure virtual destructor?

Thanks
Because when anything deriving this class gets destructed, the base class destructor will be called also. If there's no body, then you've entered undefined behavior.
If there is no body it would not build properly.

You can do
1
2
3
4
class foo{
public:
   virtual ~foo() = default;
};
Topic archived. No new replies allowed.