Actually destructor has no special role in that, try, for instance
#include <iostream>
class A
{
public:
virtual void show()=0;
};
class B: public A
{
private:
virtual void show(){ std::cout << "hi" << std::endl;}
};
int main()
{
A *p = new B();
p->show();
}
The point you spotted comes from
polymorphism (or, better, as SAK noted, from
late binding) and as strange as it looks, it is the correct behaviour, see , for instance
Public virtual function derived private in C++[
^] at
Stack Overflow.