指针与const

int i;

const int* p1=&i;

int const* p2=&i;

int *const p3=&i;

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

 

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

如:const int* p=&i;

  i=26;//OK

p=&j;//OK

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

 

posted @ 2018-07-23 15:01  Tyrants  阅读(186)  评论(0)    收藏  举报