RAD Studio
ContentsIndex
PreviousUpNext
Destructors

The destructor for a class is called to free members of an object before the object is itself destroyed. The destructor is a member function whose name is that of the class preceded by a tilde (~). A destructor cannot accept any parameters, nor will it have a return type or value declared.

#include <stdlib.h>
class X
{
public:
   ~X(){};  // destructor for class X
};

If a destructor isn’t explicitly defined for a class, the compiler generates one.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!