In C++ we use delete operator to delete objects most of the time.
The delete doesn’t make pointer value NULL. Is there any way this can be achieved automatically?
e.g.
int *p = new int;
delete p; // this should deallocate object pointed by p
// and also initialized value of p = NULL
It is simple to write one like this:
Be careful not to use this with arrays though 🙂