C++ virtual deconstructor
On this recent thread... click jfclavette asks some example questions and one of them is...
- Why should a destructor never be virtual in C++ ?
I was wondering why this is, with my understanding, having a virtual deconstructor would cause the deconstructor of a class that was dirived from this class to be called. Which is really important... But, I didn't know if I was wrong or if this was a trick question.
Thanks for the help
Yeah, my understanding's the same as yours. I thought destructors are necessary for inheritance to work right...
Making a base class destructor non virtual is one way of documenting that you don't want people to derive from your class.
Cheers
Chris
Cheers
Chris
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement