|
delete [] Buffer is right, your misunderstanding is that after you think that after release,
Buffer value should correspond to a "released" state
But in the centuries, as a pointer, it was represented as an integer (or something similar),
This integer indicates the address (physical address or virtual address) of the variable or array in memory.
After the content of the pointed address is released, this piece of memory can no longer be accessed unless
Another pointer points to it.
But your pointer variable is not like this, it still retains this integer, corresponding to a certain address,
But you do n’t need to worry, the memory pointed to has already been released correctly.
The good style is that after you delete [] buf ;, you write buf = 0, which can avoid some
Unnecessary confusion |
|