October 2004
Intermediate to advanced
240 pages
6h 22m
English
new and delete togetherThey’re a package deal: Every class-specific overload void* operator new(parms) must be accompanied by a corresponding overload void operator delete(void*, parms), where parms is a list of extra parameter types (of which the first is always std::size_t). The same goes for the array forms new[] and delete[].
You rarely need to provide a custom new or delete, but if you need one you usually need both. If you define a class-specific T::operator new to do some special allocation, it’s very likely you need to define a class-specific T::operator delete as well to do the corresponding special deallocation.
That much may be somewhat basic, but there is a subtler reason for this Item: The ...