int main() {
const int i = 0;
int* j = (int*)&i; // Deprecated form
j = const_cast<int*>(&i); // Preferred
// Can't do simultaneous additional casting:
*j=20;
cout<<*j<<"addresss "<<(int)j<<endl;
cout<<i<<"addresss "<<int(&i)<<endl;
} ///:~
The follwing code produces this output...
20addresss 2293620
0addresss 2293620
I fail to understand why?
Last edited on