¡@

Home 

c++ Programming Glossary: pmemory

How to properly free the memory allocated by placement new?

http://stackoverflow.com/questions/8918791/how-to-properly-free-the-memory-allocated-by-placement-new

Consider the folowing code Allocate memory ourself char pMemory new char sizeof MyClass Construct the object ourself MyClass.. MyClass Construct the object ourself MyClass pMyClass new pMemory MyClass The destruction of object is our duty. pMyClass ~MyClass.. normal version calls these two functions MyClass pMemory new MyClass void pMemory operator new sizeof MyClass MyClass..