Hello,
const_cast<> supposed to "cast away const" but it does not. The output is: 1002 1001, I expect it to be 1002 1002. Could someone explain what's going on? Thx.
Code:#include<iostream> using namespace std; int main(int argc, char* argv[]) { const int ci = 1001; int* i1 = const_cast<int*>(&ci); *i1 = 1002; cout << *i1 << " " << ci << endl; return 0; }