Re: How to override destructor?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Jeff Dunlap <JeffDunlap@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
I don't understand what I am doing wrong, I created a class derived
from this class:

// unmodified microsoft class
class CRequestHandlerT :

From within my subclass, I am attempting to override the destructor
above:

class CLeadsBrowser
: public CRequestHandlerT<CLeadsBrowser>
{
...
public:
...
~CLeadsBrowser()
{
// I wish to add some cleanup code here
CRequestHandlerT::~CRequestHandlerT();
}
...
};

You never stated what your problem is. Anyway, don't explicitly call
base class destructor from yours. Base class destructor will be called
automatically at the end of your destructor. Just put whatever cleanup
you need into ~CLeadsBrowser
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


.



Relevant Pages

  • Re: This says it all
    ... Cleanup code will never be reached if 'try' or 'catch' block ... executes a 'return' statement. ... Of course you should use RAII idiom (i.e. wrap resources into ... whose destructor would execute the clean up code. ...
    (comp.lang.cpp)
  • Re: Disposing. My objects wont destroy
    ... >> I've also got a class destructor in addition to a dispose. ... >> actually use it because my cleanup code is in the Dispose() method but I ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Disposing. My objects wont destroy
    ... > I've also got a class destructor in addition to a dispose. ... > actually use it because my cleanup code is in the Dispose() method but I ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Polymorphism
    ... >>So I am thinking that if the Base class destructor is not made virtual ... >>then when delete is called it won't call the derived classes ... A long time ago I posted an example of an inheritance hierarchy ...
    (alt.comp.lang.learn.c-cpp)