TITLE: why have virtual destructors [ Robert Martin had originally posted to a thread on interviewing job candidates on C++ knowledge. He stated that one question he would ask is roughly "what are the three problems you can run into by lacking a virtual destructor". -adc ] RESPONSE: kanze@gabi-soft.fr (J. Kanze) 1. The wrong address will be passed to operator delete. This will generally result in a crash. 2. The wrong size will be passed to an overloaded operator delete. Depending on how operator delete is implemented, this could also result in a crash, or it might only result in not all of the memory being freed. 3. The wrong destructor will be called. Generally, this will not cause a crash, but will likely result in some resorces not being freed. I suppose that Robert was exagerating a little when he said that all three can make the program crash. Except that all three can leak memory, and in a lot of applications, a memory leak will eventually cause a crash. RESPONSE: rmartin@oma.com (Robert C. Martin), 16 Jan 96 A bit more than that. Whenever a constructor/destructor pair are not properly conjugated the results are unpredictable. Memory leaks are the most prevalent problem, however other possibilities obtain. e.g.: Opened files not closed. Siezed Mutexes not Released File Locks not unlocked. Sentinel flags not cleared. etc, etc.....