const int n = 10;
const_cast<int &>(n) = 20;
cout << n << endl;//10
const int *p0 = &n;
cout << *p0 << endl;//20
编译器优化的结果。其实n已经被const_cast转变了,其值为20.
const int n = 10;
const_cast<int &>(n) = 20;
cout << n << endl;//10
const int *p0 = &n;
cout << *p0 << endl;//20
编译器优化的结果。其实n已经被const_cast转变了,其值为20.