If I have the following statement:
int *x = new int;
In this case, I have allocated memory on the heap dynamically. In other words, I now have a reserved
memory address for an int
object.
Say after that that I made the following:
delete x;
Which means that I freed up
the memory address on the heap.
Say after that I did the following again:
int *x = new int;
Will x
point to the same old memory address it pointed to at the heap before it was deleted?
What if I did this before delete
:
x = NULL;
And, then did this:
int *x = new int;
Will x
point to a a memory address on the heap other than the old one?
Thanks.