I tried running the following below:
#include<iostream>
using namespace std;
int main()
{
const int a = 10;
cout<<&a<<endl;
// int* p = &a; invalid conversion from const int* to int*
int* q = (int*)&a; // what is happening here?
*q=20;
cout<<q<<endl;
cout<<*q<<endl<<a<<endl;
return 0;
}
OUTPUT
0x6ffe14
0x6ffe14
20
10
If the address is same, why are results different?