数组名当参数传递的时候会退化为指针,数组长度没有实际意义,反而会误导
void foo(int* a) ;
void foo(int a[]);
void foo(int a[10]);
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
int (*matrix)[10]; //pointer to an array of 10 ints