Strange behavior of const_cast [duplicate]
This question already has an answer here: Two different values at the same memory address 6 answers Consider the following code: I declare a new reference end assign it to value a via const_cast. Then I just increase the reference value print the addresses and values. #include <iostream> using namespace std; int main() { const int a = 7; int &b = const_cast<int&>(a); ++b; cout<<"Addresses "<<&a<<" "<<&b<<endl; cout<<"Values "<<a<<" "<<b<<endl; } //output Addresses 0x7fff11f8e30c 0x7fff11f8e30c Values 7 8 How can i have 2 different values in the same address?? Modifying a constant object gives