Invoking Destructors

From RAD Studio
Jump to: navigation, search

Go Up to Destructors Index

A destructor is called implicitly when a variable goes out of its declared scope. Destructors for local variables are called when the block they are declared in is no longer active. In the case of global variables, destructors are called as part of the exit procedure after the main function.

When pointers to objects go out of scope, a destructor is not implicitly called. This means that the delete operator must be called to destroy such an object.

Destructors are called in the exact opposite order from which their corresponding constructors were called (see Order Of Calling Constructors).

See Also