指针与const

int i;spa

const int* p1=&i;co

int const* p2=&i;const

int *const p3=&i;

判断哪一个被const了的标志是const在*的前面仍是后面

 

p一、p2是同一种const,不能直接对*p赋值;p3不能进行p3++操做。

如:const int* p=&i;

  i=26;//OK

p=&j;//OK

*p=26;//出错,*在const后,不能直接对*p赋值。

相关文章
相关标签/搜索