Subtle problem with virtual keyword that can mislead the unwary...

Jason Merrill jason@cygnus.com
Fri Mar 27 13:33:00 GMT 1998


>>>>> Skip Montanaro <montanaro@crd.GE.COM> writes:

> Now, I suspect all the C++ experts reading this are way ahead of me,
> thinking, "The problem's obvious. He forgot to declare B's destructor
> virtual."  Sure enough, adding the "virtual" keyword to the
> declaration of B::~B() cures the error.

Um, no.  The problem is that you didn't define ~B.  It is automatically
virtual because ~A is.

Jason



More information about the Gcc-bugs mailing list