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 日

4K+ 次觀看

開啟你的職業生涯

完成本課程,獲得認證

開始
廣告
© . All rights reserved.