Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint

Discussion

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 compiler might be yearning for an overload of T::operator delete even when you never actually invoke it. That’s why you always need to provide operator new and operator delete (and operator new[] and operator delete[]) in pairs.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial