Why do we check for a NULL pointer before deleting in C/C++?



It is basically pointless to check for a NULL pointer before deleting. Deleting a pointer will do nothing if the pointer set to NULL. It might be the reason to check for the NULL pointer that deleting a pointer which is already set to NULL may indicate bugs in the program.

Updated on: 2019-07-30T22:30:26+05:30

488 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements