const int *p = a; *p的值为什么还可以变化
int a = 3,b = 5; const int *p = &a; p = &b; //*p = b 过不了,因为*p是const cout<<a<<", "<<b<<", "<<endl; //此时*p本来是常量3,现在变成了5,按理来说应该是不可变的啊
int a = 3,b = 5; const int *p = &a; p = &b; //*p = b 过不了,因为*p是const cout<<a<<", "<<b<<", "<<endl; //此时*p本来是常量3,现在变成了5,按理来说应该是不可变的啊
2018-07-13
举报