Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!emory!hubcap!grimlok From: grimlok@hubcap.clemson.edu (Mike Percy) Newsgroups: comp.lang.c++ Subject: Re: friend operator +(l,r) vs. operator +(r) Message-ID: <11782@hubcap.clemson.edu> Date: 21 Nov 90 18:35:02 GMT References: <11759@hubcap.clemson.edu> <1990Nov21.140621.4229@ssd.kodak.com> Organization: Clemson University, Clemson, SC Lines: 33 randolph@tuna.ssd.kodak.com (Gary L. Randolph) writes: >In article <11759@hubcap.clemson.edu> grimlok@hubcap.clemson.edu (Mike Percy) writes: [ I asked about friend operator +() vs operator +() ] >so user-defined conversion can be made on the non-foo 2. >So, if a non-foo is to be used as the left operand, a friend is preferred. >Note that friendship is only necessary for accessing a foo's private parts. ^^^^^^^^^^^^^ Good one. >If accessor functions were available, then the NONmember function is still >required, but friendship is not. So, the answer is that they are the same until a non-foo is the LHS of the binary operator. In my particular case, there are no conversions allowed (both LHS, RHS must be declared to be foo's; if not the operations are meaningless), so I could use either one, and expect the same results (please correct me if I'm wrong). My difficulties came from never considering that some classes use/provide for conversions in operations. Now, the related question: Is one prefered over the other as a stylistic point or for any other reason? Thanks for the responses, I knew I could count on the net. "I don't know about your brain, but mine is really...bossy." Mike Percy grimlok@hubcap.clemson.edu ISD, Clemson University mspercy@clemson.BITNET (803)656-3780 mspercy@clemson.clemson.edu