I'm working on some passing of arrays in C++. The following works, provided I define the array with numbers such as:
gen0[6][7].
But, I cannot call the method where I send a variable as my size parameters. I realize that I probably need to something with passing them as pointers or by reference. I read elsewhere to use unsigned int
, didn't work. I tried a few variations, but I'm struggling with the whole concept. Any tips/advice would be greatly appreciated!
//in main
int col1, col2;
col1 = rand() % 40 + 1;
col2 = rand() % 50 +1;
int gen0[col1][col2];
print(gen0)
//not in main
template<int R, int C>
void print(int (&array)[R][C])