1. 指針數組是一個數組,它的元素是一個指針。
2. 數組指針是一個指針,它指向數組的首地址。
3. 指針函數是一個函數,它的返回值是一個指針。
4. 函數指針是一個指針,它指向函數的入口地址。
指針本身是一個變量,有自己的存儲空間,又有自己的值。
理解指針常量與指針常量
const int p;
const int* p;
int const* p;
int * const p;
const int * const p;
int const * const p;
第一行是常量整數,無話可說。
后面5種是指針,有個簡便的方法記憶。
從右往左讀,遇到p就替換成“p is a”,遇到*就替換成“point to”
比如說第二行,讀作:p is a point to int const.
p是一個指向整型常量的指針。
第三行,讀作:p is a point to const int.
意思跟上面一樣。
第四行,讀作:p is a const point to int.
p是一個常量指針,指向整型。