Hello, Fred Gray has recently informed me of the procedure by which destructors are called and the difference between virtual and non virtual destructors implementation. Apparently for non virtual destructors, all inherited base destructors are called up to the level of the pointer type passed to delete. Whereas with virtual destructors, all inherited base destructors are called up to the level of the instantiated type. Given the class hierarchy class TCClass : publicTBClass { ... } class TBClass : public TAClass { ... } where TBClass *b = new TCClass; delete b; then : 1) if all classes have virtual destructors --> ~TAClass(), ~TBClass(), ~TCClass 2) if all classes have NON virtual destructors --> ~TAClass(), ~TBClass() If this is correct, shouldn't root classes (such as TObject or any root class allowed to be inherited) have their destructors implemented as virtual? William J Deninger
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:31 MET