User Profile
Collapse
-
No, Ganon11, that code didn't work with matrixes of different sizes :) I've fixed that, thanks.... -
It finally seems to work, but it looks so easy now. I don't know why I messed up with references and so. Do you see any problem to the following code?
Code:class Matrix { private: double *data; public: int nRow, nCol; Matrix (int, int); Matrix (int, int, string); double& operator() (int, int); Matrix operator+ (Matrix); Matrix operator* (Matrix);
Leave a comment:
-
Focusing in these two lines:
Code:matrix& matrix::operator*=(matrix& rhs) {...} ... { matrix tmp= matrix(*this);
If it's not matrix(*this), what's matrix(*this) supposed to be? A constructor who copies the result obtained from *this into the newly created matrix?...Leave a comment:
-
Ganon11 and JosAH:
Sorry, but I don't really catch it. I should overload the "*this", and that's done with somethig like this?
matrix matrix::operato r*=( ??? )
What should the parameter be? What should it return. Itself? With "return *this"?
Boxfish:
I had already tried to return temp itself. It works, and right, the array will remain, as the memory...Leave a comment:
-
Hi JosAH,
Thanks for your reply, but I can't fully understand what do you mean. Could you express it in another way, or sketch it with some code?
Just in case it wasn't clear (I don't know if you suggest this), I DON'T want to modify the original matrix. I want the function to give back a new one, without modifying the old one.
Thanks once again,
Guille...Leave a comment:
-
Operator overloading and parenthesis
Hi there,
I'm a new user of this forum and quite of a newbei in C/C++. I'd appreciate it if you could help me with one problem I'm having at the moment.
I've prepared a class to deal with matrices (yes, there are many of them around, but I found it a good exercise to learn all this staff). I've defined some methods with a * and + overloaded operators.
For example:
Code:Matrix& Matrix::operator*
No activity results to display
Show More
Leave a comment: