When you use placement, new is the common reason (the only reason?):
struct foo {}; void* memoryLocation = ::operator new(sizeof(foo)); foo* f = new (memoryLocation) foo();
This is mainly present in dispensers (used by containers), in the construct and destroy functions, respectively.
Otherwise, no. Stack allocation will be performed automatically, as will be the case with delete pointers. (Use smart pointers!)
Well, I suppose this is another reason: when you want undefined behavior. Then feel free to call him as many times as you want ... :)
source share