next up previous contents index
Next: Generalization of the Algorithms Up: C++ Object Instantiation Previous: new operator

delete operator

 

The delete[] operator must be used for the destruction and deallocation of the objects allocated by the new[] operator.

On the other hand, the object allocated via the new(void *) scheme must not be destructed by the delete operator, for the operator assumes the object is allocated by the new operator and the operation would destroy the consistency of the internal structure of the malloc() routine. Such object must be destructed by explicitly calling the destructor Object::~Object(). The statement

          obj->~Object();
will suffice.



Mori Tetsuya / t2y3141592@gmail.com