const int *p = &a;不管是p还是*p不是都可以更改么?那const不是就失去意义了么?代码如下
int main()
{
int a = NULL, &b = a;
const int *p = &a, *&q = p;
a = 1;
p = &b;//这两行可以分别注释看看*p和p如何变化;
cout << *p << endl;
system("pause");
}
int main()
{
int a = NULL, &b = a;
const int *p = &a, *&q = p;
a = 1;
p = &b;//这两行可以分别注释看看*p和p如何变化;
cout << *p << endl;
system("pause");
}
2018-10-09
举报