const在左在右的区别
如果const位于星号的左侧,则const就是用来修饰指针所指向的变量,即指针指向为常量;
如果const位于星号的 右侧,const就是修饰指针本身,即指针本身是常量。
1 int b = 500; 2 const int* c = &b; 3 int const *d = &b; 4 int* const e = &b; 5 const int* const f = &b; 6 *c = 1;//err 7 *d = 1;//err 8 e = &b;//err 9 f = &b;//err