數組名當參數傳遞的時候會退化為指針,數組長度沒有實際意義,反而會誤導
void foo( int * a) ;
void foo( int a[]);
void foo( int a[ 10 ]);
以上三個寫法等價。
不想讓數組退化為指針,可以通過傳遞 數組的引用來實作
void foo( int ( & a)[ 10 ]);
這個函數隻能接受長度為10的int型數組。
===============================================================
int * matrix[ 10 ]; // array of 10 pointers
int ( * matrix)[ 10 ]; // pointer to an array of 10 ints