我试图从一个函数传递一个二维数组到另一个函数。然而,该数组的大小并不是固定的,大小是由用户决定的。
我尝试研究这个问题,但没有太多的运气。大多数代码和解释都是针对数组的恒定大小。
在我的函数A中,我声明变量,然后对它进行一些操作,然后必须将其传递给函数B。
我尝试研究这个问题,但没有太多的运气。大多数代码和解释都是针对数组的恒定大小。
在我的函数A中,我声明变量,然后对它进行一些操作,然后必须将其传递给函数B。
void A()
{
int n;
cout << "What is the size?: ";
cin >> n;
int Arr[n-1][n];
//Arr gets manipulated here
B(n, Arr);
}
void B(int n, int Arr[][])
{
//printing out Arr and other things
}
int
参数。我想我那时候太轻率了。 :) - Nick Veys