Original Post
I had a small question regarding the deletion of objects allocated using the new operator.
Are objects allowed to delete (delete operator here) themselves? For example, let''s say I have a pointer to an object, say pOBJECT, that was allocated as follows.
pOBJECT = new OBJECT;
Now, let''s say that OBJECT had a member function defined as follows:
void DestroyOBJECT()
{
delete this;
}
My question comes down to this. Is the following sequence of code acceptable (ie code/syntax-wise...and from a memory deallocation perspective)?
pOBJECT = new OBJECT;
pOBJECT->DestroyOBJECT();
pOJBECT=NULL;
Thanks,
Mike