指針與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賦值。

相關文章
相關標籤/搜索