Item 8:Understand the different meanings of new and delete.(More Effective C++)
Though you want to create an object on the heap, use the
new
operator. It both allocates memory and calls a constructor for the object. If you only want to allocate memory, call operator
new
; no constructor will be called. If you want to customize the memory allocation that takes place when heap objects are created, write your own version of operator
new
and use the new
operator; it will automatically invoke your custom version of operator
new
. If you want to construct an object in memory you've already got a pointer to, use placement new
.