Newsgroups: comp.os.msdos.djgpp From: pjbk AT cee DOT hw DOT ac DOT uk (Peter JB King) Subject: Re: C++ class interaction and overloading (should be simple answer) Message-ID: Sender: news AT cee DOT hw DOT ac DOT uk (News Administrator) Organization: Dept of Computing & Electrical Engineering, Heriot-Watt University, Scotland References: <33E3B107 DOT 63DEA07F AT execulink DOT com> Date: Tue, 5 Aug 1997 10:03:43 GMT Lines: 33 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk In article <33E3B107 DOT 63DEA07F AT execulink DOT com> Jeff Weeks 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