If you set a pointer to null, the variable is deleted. It can't be used anymore and it won't take your storage anymore.
And the name for the pointer represents its value. Its value is always &someVariable
.
So could I do this: &someVariable = null;
[EDIT] I was very new to C++ when I wrote this, so I had multiple misconceptions.
To delete a pointer, you must delete ptr;
instead of setting it to null via ptr = nullptr;
.
&someVariable
is an rvalue, so it can't get anything assigned.
It's 0
, NULL
or nullptr
, not null
.
In summary, you should never delete &anything;
, even if you're lucky and it compiles. Just delete the pointer you got when allocating anything
.