我正在尝试使用数组指针作为生成数组的函数的参数.
void generateArray(int *a[], int *si){
srand(time(0));
for (int j=0;j<*si;j++)
*a[j]=(0+rand()%9);
} //end generateArray;
int main() {
const int size=5;
int a[size];
generateArray(&a, &size);
return 0;
} //end main
Run Code Online (Sandbox Code Playgroud)
但是当我编译它时,会出现以下消息:
cannot convert `int (*)[5]' to `int**' for argument `1' to `void generateArray(int**, int*)'
Run Code Online (Sandbox Code Playgroud) 我是一个完全的C++ noob,我在从我的方法返回数组时遇到了一些麻烦.我有一个头文件与以下方法声明:
virtual double[]
echoDoubleArray(double[] doubleArray, int arraySize) throw (RemoteException);
Run Code Online (Sandbox Code Playgroud)
这给了我以下错误:
../common/EchoService.h: At global scope:
../common/EchoService.h:25: error: expected unqualified-id before ‘[’ token
Run Code Online (Sandbox Code Playgroud)
返回数组的正确方法是什么?