1
2
3
4
5
6
7
8
9
|
int i = 10;
const int * p1 = &i; //这里是底层的const,能改变p1,但是不能改变*p1
//*p1 = 200 错误 p1 = &i //正确
int * const p2 = &i; //顶层const,能改变*p2,但不能改变p2
*p2 = 200; p2 = &i //错误
|
本文转自神ge 51CTO博客,原文链接:http://blog.51cto.com/12218412/1867101