It will evaluate to true, because deleting the memory allocated to a pointer does not change the value in the pointer: it remains addressing the old, freed memory. Since all valid pointers are non-zero (except one very special case: NULL)
will evaluate to non-zero, which is true.
This is one of the uses of NULL - to detect when a pointer is invalid without trying to use it
which would cause an exception if the pointer is indeed invalid.
So when you use
, set the pointer to NULL as well:
int * x = new int;
x = NULL;