我想使用一个从函数返回的二维整数数组,我应该如何定义函数的返回值?我使用了int**,但是编译器给出了错误:
int** tableCreator(){
int** table=new int[10][10];
for(int xxx=1;xxx<10;xxx++){
for(int yyy=1;yyy<10;yyy++){
table[xxx][yyy]=xxx*yyy;
}
}
return(table); //Here:cannot convert from 'int (*)[10]' to 'int **'
}发布于 2013-04-10 01:36:00
I. 数组不是指针。
II.为什么不使用vector<vector<int> >
三、若否,则:
typedef int Int10Array[10];
Int10Array *arr = new Int10Array[10];IV.为什么要写出越界?你想要露骨的鼻魔吗?
for(int xxx = 0; xxx < 10; xxx++)
^^^ ^^^^https://stackoverflow.com/questions/15908632
复制相似问题