C++ deleting a pointer
- by eSKay
On this page, its written that
One reason is that the operand of
delete need not be an lvalue.
Consider:
delete p+1;
delete f(x);
Here, the
implementation of delete does not have
a pointer to which it can assign zero.
Adding a number to a pointer shifts it forward in memory by those many number of sizeof(*p) units.
So, what is the difference between delete p and delete p+1, and why would making the pointer 0 only be a problem with delete p+1?