From: Chris Mangum and Savanna Judd Newsgroups: comp.os.msdos.djgpp Subject: Re: C++ class interaction and overloading (should be simple answer) Date: Sun, 03 Aug 1997 08:02:49 -0700 Organization: Cruzio Community Networking Service Lines: 24 Message-ID: <33E49D99.6C14@cruzio.com> References: <33E3B107 DOT 63DEA07F AT execulink DOT com> NNTP-Posting-Host: tech10.cruzio.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Jeff Weeks wrote: > > 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? > inline friend Vector operator * (Matrix& mat, Vector& vect); I believe your problem here is just the order of the operands. The first parameter in the overload function always corresponds to the left-most operand, and the second parameter is the right operand. Thus, with your class declaration, I believe that Vector2 = Matrix1 * Vector1 would work. In order to get it to work the other way, with the operands in the original order, I believe you'll have to add a second operator* member with the paramaters as (Vector& vect, Matrix& mat) -Chris Mangum -sneeches AT cruzio DOT com