Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!psuvax1!rutgers!att!cbnewsl!dog From: dog@cbnewsl.ATT.COM (edward.n.schiebel) Newsgroups: comp.lang.c++ Subject: Re: coercion of x op= y verses x = x op y ??? Message-ID: <2209@cbnewsl.ATT.COM> Date: 11 Oct 89 11:44:04 GMT References: <6590286@hplsla.HP.COM> Organization: AT&T Bell Laboratories Lines: 20 From article <6590286@hplsla.HP.COM>, by jima@hplsla.HP.COM (Jim Adcock): >>In the second case, you are either applying a "*=" operator to an Int (no >>such operator defined), or to an int (which is generated by a function >>call, which is not an lvalue). > > In which case, seems to me that coercion oerators should be considered to > return a reference, so as to be legal in lvalue situations. Otherwise > you can't use coercion operators for true polymorphism. Where is it defined > whether coercion operators return values or lvalues? Is there anyway to > declare which you'd like? You get to declare the coercion operators, so you decide. In general, the operators might not return a reference since the result may be computed. Also, you may not want to allow the coercion operator to return a reference to private data anyway as this violates data hiding principles. Ed Schiebel AT&T Bell Laboratories dog@vilya.att.com