I find that in the following code snippet
const int i = 2;
const int* ptr1= &i;
int* ptr2 = (int*)ptr1;
*ptr2 =3;
i
's value changes to 3. What I could like to know is why is this allowed. What are the situations in which this could become helpful?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…