我喜歡這樣寫(xiě):int num = 100;
int* p = #
int& q = num;
...
int* p = #
int& q = num;
...
2015-08-09
說(shuō)一個(gè)比較好記的方法來(lái)區(qū)分 int const *p與 int* const p,把*讀作pointer to然后從后往前讀.
第一個(gè)int const *p就可以讀作 p is a pointer to const int,p是指向常量的指針
第二個(gè)int* const p就可以讀作 p is a const pointer to int,p是指向int型的常指針
第一個(gè)int const *p就可以讀作 p is a pointer to const int,p是指向常量的指針
第二個(gè)int* const p就可以讀作 p is a const pointer to int,p是指向int型的常指針
2015-08-03
可變的指針去指向不可變的變量是錯(cuò)的
const int *p 常指針
int *const p 指向常量的指針
const int *const p 指向常量的常指針
const int *p 常指針
int *const p 指向常量的指針
const int *const p 指向常量的常指針
2015-08-03