Destructor not being called
-
I am having an object inherited from abstract base class (having some pure virtual functions). My problem is this: I create some objects of that type by calling new, and when I later call delete on them destructor is not being called! Destructor is simple (public, not virtual). Is there any open bug in Visual C++ compiler regarding this ? Miroslav Rajcic http://www.spacetide.com
-
I am having an object inherited from abstract base class (having some pure virtual functions). My problem is this: I create some objects of that type by calling new, and when I later call delete on them destructor is not being called! Destructor is simple (public, not virtual). Is there any open bug in Visual C++ compiler regarding this ? Miroslav Rajcic http://www.spacetide.com
-
Which destructor? If you are talking about the base-class destructor, this is a classic one. The destructor must be virtual
Both base class destructor and inherited class destructor are plain public. So, do you say that I must convert one of them to virtual? Miroslav Rajcic http://www.spacetide.com
-
Both base class destructor and inherited class destructor are plain public. So, do you say that I must convert one of them to virtual? Miroslav Rajcic http://www.spacetide.com
Absolutely - your base class destructor must be virtual. This is how, for example, the designers of the string class stopped people deriving from it, they didn't make the destructor virtual. Christian #include "std_disclaimer.h" People who love sausage and respect the law should never watch either one being made. The things that come to those who wait are usually the things left by those who got there first.
-
Which destructor? If you are talking about the base-class destructor, this is a classic one. The destructor must be virtual
I tried your tip and it works now :) I have declared base class destructor as virtual. Thanks again. Miroslav Rajcic http://www.spacetide.com