I am using const_cast to remove the constness of an integer.
#include<iostream>
int main(){
const int pi = 3;
int & pie = const_cast<int &>(pi);
pie = 4;
std::cout<<pi << " " << &pi << " " << pie << " " << &pie << std::endl;
};
Output:
root@ubuntu-OptiPlex-380:~/cpp# ./a.out
3 0x7fffdbc66f1c 4 0x7fffdbc66f1c
Can anyone kindly explain how the same memory location can hold different values?