传递未知大小的二维数组的正确方法是什么?
reprVectorsTree::reprVectorsTree(float tree[][], int noOfVectors, int dimensions)
如何在函数后面访问这个数组的元素?
如何从调用函数传递二维数组?
-----编辑----
我想处理一个数组,因为调用是从 c 代码完成的,并且有一个 c 到 c++ 的接口(interface)
-----编辑----- 如何定义从调用函数传递二维数组?
float tree[15][2] = {{2,1},{2,1},{2,1},{2,1},{2,1},{2,1},{2,1},{2,1},{2,1},{2,1},{2,1},{2,1},{2,1},{2,1},{2,1}};
reprVectorsTree *r1 = new reprVectorsTree(tree[0][0],8,2);
上面的代码有什么问题? 我收到无法将参数 1 从“float”转换为“float **”
最佳答案
使用指针..
reprVectorsTree(tree, noOfVectors, dimensions);// Calling function.
函数定义:
reprVectorsTree(float **tree, int noOfVectors, int dimensions){
}
我想这对你有帮助。
关于c++ - 如果在编译时两个维度都未知,如何传递二维数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11982038/