I read the following code for deleting pointer object in the open source project X3C.
//! Delete pointer object.
/*!
\ingroup _GROUP_UTILFUNC
\param p pointer object created using 'new'.
*/
template<class T>
void SafeDelete(T*& p)
{
if (p != NULL)
delete p;
p = NULL;
*(&p) = NULL;
}
But I don't know the meaning of this line:
*(&p) = NULL;
In the above line(p = NULL;), p is assigned to NULL. I think it needs to do that again in another way.
*(&x) = NULL;
thing forSafeDeleteArray
weirdly. – Kronick