Hello :)
(Too many questions about this)!
Basically, I'm trying to display the contents of a matrix without using "cout" in my class. (It's a bad method)
I've tried to return an array, but, that failed miserably.. So I've got a method in my class:
double Matrix::read(int theRow, int theColumn)
{
return matrix[theRow*rows*theColumn];
}
(This basically returns the elements of matrix according to theRow, theColumn)
In order to display the complete matrix, I have to use this algorithm:
matrix[i*rows+j]
i = for loop
j = for loop
e.g.
void Matrix::displayMatrix()
{
for (int i=0; i<columns; i++){
for (int j=0; j<rows; j++){
cout<< matrix[i*rows+j] << "\t";
}
cout<<"\n";
}
}
Is there a way I can replicate this inside main.. Something like this:
for(int i=0; (i < columns); i++)
{
for(int j=0; (j < rows); j++)
{
cout << m.read(ALGORITHM) << "\t";
}
cout << endl;
}
If that makes sense? Hope someone can help, it's been annoying me!