done

cout << "This question is done"; Thank you all for the help
Last edited on
I think for your matrix operations, all you would need is
1
2
3
4
5
6
7
for(unsigned long i = 0; i < MAXROWS; ++i)
{
	for(unsigned long l = 0; l < MAXCOLS; ++l)
	{
		//Do stuff with elements[i][l] and array[i][l] or other.elements[i][l]
	}
}
Last edited on
cout << "This question is done";
Last edited on
OK, so, what is confusing you?
cout << "This question is done";
Last edited on
Have you tried this?
1
2
3
4
5
6
7
8
9
10
11
12
void Matrix::display()
{
	for(unsigned long i = 0; i < MAXROWS; ++i)
	{
		cout << '[';
		for(unsigned long l = 0; l < MAXCOLS; ++l)
		{
			cout << ' ' << elements[i][l] << ' ';
		}
		cout << ']' << endl;
	}
}
cout << "This question is done";
Last edited on
Well, obviously you need to initialize your array or it will just be left over data. Do this in the constructor. ;)
cout << "This question is done";
Last edited on
MAXROWS and MAXCOLS are macros. They would expand to 3, so your code is essentially the same as this:
1
2
3 = m.3;
3 = m.3;
See the problem?
cout << "This question is done";
Last edited on
I can't help but notice that there are no vectors in this problem.

swalton: Can you assign a variable to a constant? That's why there's a problem in those lines.

-Albatross
cout << "This question is done";
Last edited on
I wonder where you got this code from, then. People usually don't teach operator overloading until way after there's a good understanding of the non-overloaded operators and their use; this code is more advanced that what you seem to know. Just sayin'.

Anyways, you're assigning a constant (3) the value of... wait a sec... something which doesn't seem to exist. Matrix::m::3 does not exist.

What do you want += to do?

-Albatross
Last edited on
cout << "This question is done";
Last edited on
Everything you want to do here will need the loop.
1
2
3
4
5
6
7
8
9
10
Matrix::Matrix()
{
	for(unsigned long i = 0; i < MAXROWS; ++i)
	{
		for(unsigned long l = 0; l < MAXCOLS; ++l)
		{
			elements[i][l] = 0;
		}
	}
}


Also, you don't seem to understand macros and constants. Please read this:
http://www.cplusplus.com/doc/tutorial/preprocessor/
Last edited on
Topic archived. No new replies allowed.