Follow - useful in embedded systems and other low-level...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Follow-up on Placement New/Delete Jonathan Schilling, [email protected] Also introduced in Newsletter #019 were placement new and placement delete. In addition to the language providing this general capability, the C++ standard library also provides a specific instance for void*: void* operator new(size_t, void*); void operator delete(void*, void*); These are accessed by saying: #include <new> These functions are defined to do nothing (though new returns its argument). Their purpose is to allow construction of an object at a specific address, which is often
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: useful in embedded systems and other low-level applications: const unsigned long MEMORY_MAP_IO_AREA = 0xf008; ... Some_Class* p = new ((void*) MEMORY_MAP_IO_AREA) Some_Class(); Based on a fairly recent decision of the standards committee, this definition of placement new/delete for void* is reserved by the library, and cannot be replaced by the user (unlike the normal global operator new, which can be). The library also defines a similar placement new/delete for allocating arrays at a specific address....
View Full Document

This note was uploaded on 02/27/2012 for the course CS 251 taught by Professor Staff during the Fall '08 term at Purdue.

Ask a homework question - tutors are online