Suppose I have a matrix M x N dimension.

Normally, to print all of the elements in the matrix. I write the

following codes:

Suppose M = 5, N = 4:

for(int j=0; j<5; ++j) {

for(int k=0; k<4; ++k) {

cout << matrix[M][N] << " ";

}

cout << endl;

}

If my matrix class has method for return number of dimension and

dimension size such as:

numDimension(ma trix); // return 2 becase the matrix has M x N = 2

dimensions.

sizeDimension(0 ); // return 5 -- size of M

sizeDimension(1 ); // return 4 -- size of N

How to write some code that print all element of the matrix with out

code nested loops by hand?

Thanks

Nalerk