NULL
The pointer doesn't point at anything, so there's nothing to do with delete
Is it safe to delete
?
Should I check whether it is NULL
or not and delete?
delete
will check it on its own.
Checking NULL
and delete
is double checking, it's useless, and the code gets messy, so don't do it.
The best method for delete
is:
delete
Make one pointer NULL
.
This will prevent you from delete
and prevent memory from being corrupted.
© 2024 OneMinuteCode. All rights reserved.