const int * a、int * const a、int const * a、const int * const a

理解下面四者的区别:
const int * a;
int * const a;
int const * a;
const int * const a;

很好理解:
把*改为(point to),并从右往左念:
const int (point to) a;/*即a指向const int型的指针变量*/
int (point to) const a;/*const a指向int型的指针变量*/
int const (point to) a;/*a指向int const型的指针变量。
						其实int const和const int一样*/
const int (point to) const a;/*const a指向const int型的
									指针变量*/

猜你喜欢

转载自blog.csdn.net/weixin_45519751/article/details/108592544