RosettaCodeData/Task/Memory-allocation/C++/memory-allocation-8.cpp

10 lines
280 B
C++

class MyClass { /*...*/ };
int main()
{
MyClass* p = new(whatever) MyClass; // allocate memory for myclass from arena and construct a MyClass object there
// ...
p->~MyClass(); // explicitly destruct *p
operator delete(p, whatever); // explicitly deallocate the memory
}