February 2005
Beginner to intermediate
272 pages
4h 53m
English
Sometimes it’s a good idea to indicate that objects of a particular class should not be allocated on the heap. Often this is to ensure that the object’s destructor is called, as in the case of a “handle” object that maintains a reference count for a “body” object. Local objects with automatic storage class will have their destructors called automatically (except in the case of abnormal program termination via an exit or abort), as will objects with static storage class (except in the case of an abort), whereas heap-allocated objects must be destroyed explicitly.
One way to indicate such a preference is by defining heap memory allocation to be illegal:
Any conventional attempt to allocate a NoHeap object ...
Read now
Unlock full access