I use Borland C++ Builder.
And i had o problem
#include <Classes.hpp>
class TMyObject : public TObject
{
__fastcall TMyObject();
__fastcall ~TMyObject();//I would like to inherite my destructor from TObject
};
__fastcall TMyObject::TMyObject() : TObject()//it will inherited my constructor from TObject
{
}
And for that new destructor that will inherite ~TObject?
__fastcall TMyObject::~TMyObject?????????????
This can be solved at
TObject‘s level. Its destructor has to be virtual:This way you can either do:
or
Both destructors will be called (
~TMyObject()first and then~TObject()) and you will have no leak.