A pure virtual function must be implemented if called. So for example:
struct A { virtual void f() = 0; }; struct B : A { void f(); }; void B::f() { std::cout << "B::f called\n"; }
However, if B::f calls A::f , then A::f must be implemented:
void B::f() { A::f(); std::cout << "B::f called\n"; }
With this definition of B::f must also be a definition of A::f .
The same thing with a virtual destructor: if it called, it must be implemented. For the destructor, the difference is that the destructor in the base class is always called by the destructor for the derived class, so you should always implement a pure virtual destructor. Even if it does nothing.
source share