class Matrix
{
public:
int M;
int N;
double *ptr;
Matrix(int m,int n)//constructor takes two ints
{
M = m;
N = n;
ptr = new double[M][N];
assign(M,N);//call function
}
void assign(int M,int N)// method
{
for(int i = 0; i < M;i++)// i is a row
{
for (int j = 0; j < N; j++)// j is a column
{
ptr[M][N] = (double) 1000 + i * N + j;
cout << ptr[M][N] << "\t"; //print values
}//end for loop j
cout << "\n";//print newline
}//end for loop i
}//end assign
};
Hello, the above code works fine when I use a 1d array to output the values. But when I attempt to do the same using a 2d array like above, it gives me errors. Anybody help?
Thanks.