C++ for Java Programmers
“Tsk, tsk,” said the Hatter, “what a mess you’ve made.”
“It is perfectly fine,” replied Alice calmly. “I will leave it for the garbage collection service to recover.”
“Don’t expect any garbage collection here. Furthermore, your polymorphic variables won’t ever be properly deleted, because you haven’t declared your destructor to be virtual.”
“My what to be what?” said Alice, starting to get worried.
“Declare your destructor. You must have a destructor. Everything that is constructed should be destroyed; it’s only natural. Furthermore, if you are ever not quite what you seem, you should declare yourself to be virtual.”
“A rule to remember!” roared the Red Queen. “Never make a mess without cleaning it up first.”
“You can ignore her,” whispered the Dormouse, picking up the tea cake Alice had just set aside, “but you shouldn’t cast away const
so lightly.”
Alice began to feel that this new world she found herself in was not quite the same as the cozy sitting room she had just left.
Timothy Budd: C++ for Java Programmers