Is it normal that after deleting a dynamic variable from memory, its address can still be obtained?
Closed due to the fact that the essence of the issue is not clear by the participants user194374, pavel , aleksandr barakin , Nicolas Chabanovsky ♦ Aug 7 '16 at 5:49 .
Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .
- fourthis is not quite normal when you take screenshots instead of code - strangeqargo
- 2Welcome to Stack Overflow in Russian ! It is better to provide textual information in the form of text, not images: it is more convenient to read, and search engines will index it. You can change the question by clicking the edit below question text. - aleksandr barakin
2 answers
Yes, it is normal and even allowed.
In your case, you get the address is not a remote memory, and the pointer , which is not deleted at all. You have a
- only a pointer to the memory that you allocate, and he, like any variable, also has an address.
“Remote” variable - *a
. To her, you, oddly enough, could also appeal. (But remote variables cannot be accessed. The compiler trusts you and does not track these hits, so they are on your conscience.)
Full Here was a metaphorical detailed answer to this topic (in English): https://stackoverflow.com/questions/6441218/can-a-local-variables-memory-be-accessed-outside-its-scope/6445794#6445794
Usually, after removing a dynamic variable, it is recommended to reset the pointer to it so that its address is no longer available.