Is it used when assigning NULL to a pointer after deleting it in a destructor in C ++?

Possible duplicate:
Is it worth pointing to pointers to NULL in the destructor?

I see code like this,

void ClassA::~ClassA()
{

delete member;
member = NULL;

}

since a particular instance no longer exists after this destructor (or the instance is destroyed and its members can no longer be used or dereferenced), what is the use of assigning NULL to the pointer of a member variable?

Is it just a practice of deleting a pointer elsewhere and assigning it NULL?

+3
source share
4 answers

, , - " ". " ", , -, " ".

0

- , .

+4

This is pointless for release code, but potentially useful for debugging.

+1
source

Yes, this is just good practice. helps to remember to point to pointers to zero elsewhere;)

-2
source

Source: https://habr.com/ru/post/1784900/


All Articles