Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!comp.vuw.ac.nz!actrix!Bruce.Hoult From: Bruce.Hoult@bbs.actrix.gen.nz Newsgroups: comp.lang.c++ Subject: Re: friend operator +(l,r) vs. operator +(r) Message-ID: <1990Nov21.053431.22340@actrix.co.nz> Date: 21 Nov 90 05:34:31 GMT References: <11759@hubcap.clemson.edu> Sender: Bruce.Hoult@actrix.co.nz (Bruce Hoult) Organization: Actrix Information Exchange, Wellington, New Zealand Lines: 29 Comment-To: grimlok@hubcap.clemson.edu In article <11759@hubcap.clemson.edu> grimlok@hubcap.clemson.edu (Mike Percy) writes: > I've tried and tried to get a handle on this question from various > sources, but haven't been enlightened... > > What semantic/operational and/or stylistic differences are there > between these two definitions? > > class foo { > ... > public: > foo& operator +(foo& rhs); > } > > and > > class foo { > ... > public: > friend foo& operator +(foo& lhs, foo&rhs); > } > > I must be missing something, because to me these effectively are the > same thing, but the first can operate on this. The important difference is that the friend version allows implicit conversions to be made on both the left hand and right hand arguments to +, wheras the member function version allows implicit conversions on only the RH argument.