+ 5
what is the C++ code doing?
int* ptr = new int(27); *ptr = 34; ... delete ptr; so 1. ptr is a pointer with a value 27 2. value at ptr is changed to 34 3. delete ptr
2 Respostas
+ 7
You're right. If you write cout << ptr; after the delete ptr; instruction, you'll get the place of the pointer in the memory, like 0x681640, or 0x351640 (check this code: https://code.sololearn.com/cZb0fb74VU11/?ref=app).
+ 2
yeee! ... I'm abit confused about this part
*ptr=34;
I thought it's changing value at ptr to 34.when I do
cout << *ptr <<endln;
the value is 8327888