个人博客 http://www.milovetingting.cn C++中的常量指针和指针常量常量指针123456789101112int a = 1;int b = 2;//定义一个常量指针const int *p = &a;cout << *p << endl;//输出1p = &b;cout << *p << endl;//输出2//报错,常量指针不可以修改指针指向的值//*p = 2; 指针常量123456789101112int a = 1; int b = 2; int * const p = &a; cout << *p << endl;//输出1 *p = 2; cout << *p << endl;//输出2 cout << a << endl;//输出2 //报错,指针常量不可以修改指针的指向 //p = &b;