#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
const int a = 1;
int* b;
b = (int*)&a;
*b = 6;
cout << &a << endl;
cout << b << endl;
cout << a << endl;
cout << *(&a) << endl;
cout << *b << endl;
return 0;
}
The output is as follows:
0x7ffc42aeb464
0x7ffc42aeb464
1
1
6
As the result, the memory address is same but the value is different. What is the reason?