I have some trouble with understanding how does the const_cast
work.
const int i = 10;
int *j = 0;
j = const_cast<*int>(&i);
*j += 10;
So far so good, but:
&i == j && i == 10 && *j == 20
is true. Why?! This is... hmm... surprising, I have no idea how to explain this :(
Aucun commentaire:
Enregistrer un commentaire