Hacker News new | ask | show | jobs
by android2 5689 days ago
"To work correctly, classes with virtual methods must also have virtual destructors."

Not a good way to start the article... I immediately question the author's credibility following this statement.

1 comments

Why? If they don't it is going to mess up the destruction sequence if they are ever stored and then released polymorphically, such as from a collection of pointers to classes.

What he is saying is standard C++ knowledge.

You can also use a protected non-virtual destructor in the base class to avoid to mess up the destruction sequence. But what he says is indeed the most common case.
Sometimes an alternative is to make the destructor in the base class protected.