What i understand is if you use the "delete" operator on a pointer pointing to a memory address on the heap, it frees up the memory. I wrote this piece of code to test my knowledge but even after using the delete operator the memory address still has the value at the address. Can anyone please explain what is going on here?
#include <iostream>
using namespace std;
int main()
{
int* aPtr = new int(5);
cout << "address of int in heap is " << aPtr << endl;
cout << "value of int in heap is " << *aPtr << endl;
delete aPtr;
cout << "address of int in heap is " << aPtr << endl;
cout << "value of int in heap is " << *aPtr << endl;
return 0;
}
The console output I got is here,
address of int in heap is 0x7fe851402700
value of int in heap is 5
address of int in heap is 0x7fe851402700
value of int in heap is 5