const int c= 7 ;
const int * b= &c ;
int *a = (int *)b ;
*a = 6;
cout<<*a<<endl;
cout<<*b<<endl;
cout<<c<<endl;
I run it by g++ complier , and the output is :
6
6
7
I know it's inadvisable, but I am confused with it. I think the pointer b points to c , which is const , but why *b is changed to 6 while c is still equal to 7 ? they refer to the same stuff , why different?
could you explain how this code works internally ?