I have defined an array of vectors, and want to pass this array to a function.
Here's my code:
void gridlist(std::vector<int> *grid, int rows, int cols){
..... }
int rows=4;
int cols=5;
std::vector<int> grid[rows][cols];
gridlist(grid,rows,cols);
The only method which has worked for me to pass arrays to a function was by pointer (*) ?.
I've tried different method according to following descriptions: Passing a 2D array to a C++ function, but I didn't manage to get it working.
I always get the following error:
could not convert '(std::vector<int> (*)[cols])(& grid)' from 'std::vector<int> (*)[cols]' to 'std::vector<int>'
gridlist(grid,rows, cols);
I don't know what I am doing wrong. What is, in general, considered the best/safest method to do that task?