C/C++ 中 const int*,const int * const 和 int const * 之間的區別?


以上符號的含義如下 −

int* - Pointer to int. This one is pretty obvious.
int const * - Pointer to const int.
int * const - Const pointer to int
int const * const - Const pointer to const int

還要注意如下內容 −

const int * And int const * are the same.
const int * const And int const * const are the same.

如果你在閱讀這些符號時遇到混淆,請記住螺旋規則:從變數的名稱開始,順時針移動到下一個指標或型別。重複此過程,直到表示式結束。

更新於: 2020 年 2 月 11 日

4 千 + 瀏覽

啟程你的 職業

完成課程,獲得認證

開始學習
廣告