I'm trying to pass a 2D matrix with dimensions entered by the user to a function, for example arrayTest[r][c]. I've done my research and cannot find an answer that works. I'm using codeblocks on windows if that matters.
My Code:
#include <iostream>
using namespace std;
int r, c;
template <size_t r, size_t c>
void printMatrix(double (&matrix)[r][c])
{
for(int i=0;i<r;i++)
{
for(int j=0;j<c;j++)
{
cout<<matrix[i][j]<<" ";
}
cout<<endl;
}
}
int main()
{
r = 1;
c = 1;
double matrix[r][c] = { { } };
printMatrix(matrix);
return 0;
}
I currently get the error: no matching function for call printMatrix.