Overloading The Operator delete

From RAD Studio
Jump to: navigation, search

Go Up to The new And delete Operators Index

The global operators, ::operator delete(), and ::operator delete[]() cannot be overloaded. However, you can override the default version of each of these operators with your own implementation. Only one instance of each global delete function can exist in the program.

The user-defined operator delete must have a void return type and void * as its first argument; a second argument of type size_t is optional. A class T can define at most one version of each of T::operator delete[]() and T::operator delete(). To overload the delete operators, use the following prototypes.

void operator delete(void *Type_ptr, [size_t Type_size]);    // For Non-array
void operator delete[](size_t Type_ptr, [size_t Type_size]); // For arrays

See Also