天天看點

const指針

const指針有三種形式:

         1)const出現在*左邊

         2)const出現在*右邊

         3)   const出現在*兩側

const出現在*左邊表示被指對象是常量;出現在右邊表示指針自身是常量;出現在兩側表示被指對象和指針本身都是常量。

const指針
const指針
const指針

另外, int const *p與 const int *p是等價的,即隻有當const與*相對位置發生變化才有差別。

繼續閱讀