Mail Archives: djgpp/1997/08/08/21:57:13
In article <33E3B107 DOT 63DEA07F AT execulink DOT com> Jeff Weeks <pweeks AT execulink DOT com> writes:
>Hi there...
>
>I've got a C++ problem here. I've defined a two classes: Vector and
>Matrix. I'd like to be able to do this:
>
>Vector2 = Vector1 * Matrix1
>
>But I can't get that to work. Is this possible?
>
>What I tried was this (in my Vector class):
>
>class Vector {
> ...
> public:
> inline friend Vector operator * (Matrix& mat, Vector& vect);
> ...
>};
...
>I'm afraid I can't remember the error I got (and I'm in Linux now so I
>can't check...). It was something along the lines of, "Can't find
>operator to math that expression" :)
>
The problem is that you have defined an operator for
Matrix * Vector,
not one for
Vector * Matrix.
--
Peter King, Computing & Electrical Eng. Internet: pjbk AT cee DOT hw DOT ac DOT uk
Heriot-Watt University, Riccarton, or P DOT J DOT B DOT King AT heriot-watt DOT ac DOT uk
Edinburgh EH14 4AS, Scotland
Phone: (+44) 131 451 3433 Fax: (+44) 131 451 3431
- Raw text -