Aricent Interview Question
Software Engineer in TestsThe C++ Standard states that it is perfectly valid to delete a null pointer.
So nothing would happen in the above case.
Deleting a pointer means you are deallocating the space to the object which the pointer points to.
After using
{delete p;}
Pointer is still there and pointing to the same memory, but the memory may have different data now and may result in different behaviour of the pointer.
so it should be set to null after using delete pointer;
A pointer is deleted after the execution of the block like any other object.
(manish.kr85@yahoo.com)
there is no error in deleting a null pointer.
- Anonymous October 24, 2008