-1
同时读取C++二维数组,我们可以在
这样一种方式宣告我打:二维数组让我处境艰难
month=4;. // Initialize value of mont variable
void display(float [ ] [month]); //declare
我想知道,为什么功能并不需要的拳头大小尺寸 ?
我在很多论坛上问这个问题,但只得到如何声明这样的数组。但从来没有找到答案为什么?
同时读取C++二维数组,我们可以在
这样一种方式宣告我打:二维数组让我处境艰难
month=4;. // Initialize value of mont variable
void display(float [ ] [month]); //declare
我想知道,为什么功能并不需要的拳头大小尺寸 ?
我在很多论坛上问这个问题,但只得到如何声明这样的数组。但从来没有找到答案为什么?
因为传递给函数的数组被视为指针(对数组的第一个元素)。
所以像
float month[][X]
参数声明等于
float (*month)[X]
所以month
是指向float
类型的X
元件的阵列。
这是因为“2d”阵列实际上是阵列的阵列。 C++并没有真正的多维数组。
另请注意,array of arrays is not the same as a pointer to a pointer。对指针的衰减只发生在外部数组(“第一维”)。