Hello,
I am a some what new C++ guy, and I am looking at someone else's code and this method of newing and deleting seems odd to me.
Is there anything wrong with this method of deleting?
first new an object:
Code:
Object *pObject = new Object;
Later when the object is deleted:
Code:
if (pObject != NULL)
{
Object *pTemp = pObject;
pObject = NULL;
delete pTemp;
}
It seems to me that they are just deleting the pointer to pObject, and not actually reclaiming the memory. I am wondering why not just delete pObject, and then null Pobject pointer?
Any help would be much appreciated!
Thanks