what is this the correct way to pass 2 dimensional array of unknown size?
reprVectorsTree::reprVectorsTree(float tree[][], int noOfVectors, int dimensions)
<
First idea was to use vectors. But if you are working with a C code, pass it as a reprVectorsTree(float** tree, int noOfVectors, int dimensions)
.
For your case:
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}};
int nRows = 15;
int nCols = 2;
float** arr = new float*[nRows];
for (int i = 0; i < nRows; ++i) {
arr[i] = new float[nCols];
}
for (int i = 0; i < nRows; ++i) {
for (int j = 0; j < nCols; ++j) {
arr[i][j] = tree[i][j];
}
}
reprVectorsTree *r1 = new reprVectorsTree(arr, nRows, nCols);