C++ Language/Objects/Constructors/PlacementNew

From Wikibooks, open books for an open world
Jump to navigation Jump to search

C++'s new operator allocates memory, and then executes some constructor within that memory. Low-level software might already have some memory pre-allocated for a new object, only wanting to run its constructor. To do so, call a "placement new" as CRType* poVar = new (preallocation) CRType;.

Additional information about placement new