Destructors

Top  Previous  Next

What is translated > Types > Records, Classes, Interfaces > Class > Destructors

 

In Delphi a declaration of a destructor start with the keyword destructor followed  by an arbitrary name. In C++ the name of the of the class is also the name of the destructor preceded by the the character '~'.

 

destructor classname.foo;    ->   __fastcall classname::~classname ( )

 

 

Delphi2Cpp tempts to find calls of destructors of the base class and to comment them out in C++. Thereby is assumed that the destructor of the base class is virtual. That's the case for all classes, which are derived from TObject.

 

 

destructor foo.Destroy();   ->    __fastcall foo::~foo ( )

begin                             {                                                           

  FreeAndNil(m_Messages);           FreeAndNil ( m_Messages );                               

  inherited Destroy;                // todo check:  inherited::Destroy;                  

end;  

 

In Delphi parameters can be passed to destructors, but this isn't possible in C++.

For destructors analogous problems can occur as for constructors, but they are very rare.

 



This page belongs to the Delphi2Cpp Documentation

Delphi2Cpp home  Content