const_cast: same address but different value? [duplicate]
问题 This question already has answers here : Two different values at the same memory address (7 answers) Closed 2 years ago . New to C++ and learning the const_cast — get really confused by the code below: int main(){ const int j = 1; int * p = (int *)(&j); cout << j << ' ' << *p << endl; cout << &j << ' ' << p << endl; *p = 2; cout << j << ' ' << *p << endl; cout << &j << ' ' << p << endl; const int k = 1; int * q = const_cast<int*>(&k); cout << k << ' ' << *q << endl; cout << &k << ' ' << q <<