#include<bits/stdc++.h>
using namespace std;
class test
{
int a, b;
public:
void intake(int x, int y)
{
a=x;
b=y;
}
void print(int mat[a][b])
{
for (int i = 0; i < a; i++)
{
for (int j = 0; j < b; j++)
{
cout<<mat[i][j]<<" ";
}
}
}
};
int main()
{
int mat[3][2] = {{2,3},{4,5},{6,7}};
test arr;
arr.intake(3,2);
arr.print(mat);
return 0;
}
I was trying to pass the values of the 2-dimensional array as variable, I tried this using class but it retrieves the error "a nonstatic member reference must be relative to a specific object".
The above code is having error and I need help to solve it.