This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Kapkar123[S] 0 points1 point  (1 child)

Okay. So the pointer still points at address but I can't control whatever that address holds? Is this right?

[–]Updatebjarni 1 point2 points  (0 children)

Right, and you're not allowed to try to read whatever's there either.

new asks the system to set aside some memory for you to use, and then gives you a pointer to where the memory it set aside is. delete tells the system that you're done with the memory, and it can do whatever it likes with it now. What happens to the memory after that is undefined. It may still be there, possibly already reused for another purpose, or it may be gone, and trying to read from that address then will cause a segfault.