Is there any reason to check for a NULL pointer before deleting?

It’s perfectly “safe” to delete a null pointer; it effectively amounts to a no-op.

The reason you might want to check for null before you delete is that trying to delete a null pointer could indicate a bug in your program.

Edit

NOTE: if you overload the delete operator, it may no longer be “safe” to delete NULL

Leave a Comment