like now value is deleted why does it show adress shouldnt show junk value
Some common misconceptions about delete:
1) delete ptr; does not actually delete the pointer. It deletes the data that the pointer points to. When you do newint; you are creating a new unnamed integer... and then your 'ptr' pointer points to that integer. When you delete ptr you are deleting the unnamed integer, but are not changing 'ptr' at all.
2) Deleting a basic type like an int simply de-allcates memory. It does not [necessarily] fill that memory with garbage values. So it's very possible that the data will still be in that memory even after the data is deleted. Though it isn't guaranteed, as that memory may get allocated somewhere else and/or be overwritten by something else.
Topic archived. No new replies allowed.
You are using a version without Ads of this website. Please, consider donating: