Xref: utzoo comp.lang.c++:4294 gnu.g++:329 Path: utzoo!utgpu!watmath!uunet!lll-winken!pacbell!att!cbnewsl!dog From: dog@cbnewsl.ATT.COM (edward.n.schiebel) Newsgroups: comp.lang.c++,gnu.g++ Subject: Re: What's the diff? Message-ID: <1389@cbnewsl.ATT.COM> Date: 7 Aug 89 12:27:39 GMT References: <119611@sun.Eng.Sun.COM> Organization: AT&T Bell Laboratories Lines: 24 From article <119611@sun.Eng.Sun.COM>, by acw%illini@Sun.COM (Alex Wu [GPD] x6-6874): >> these two examples? The Lippman book (p. 197) prefers to define the >> function type to return a reference to the class while the Pohl book >> (p. 125) seems to prefer to return the class. Both seem to work >> equally well as both lvalue and rvalue. >> ... > One difference I can think of is that the first class allows > the cascade of "++" in this case, that is: > > counter i; > (i++)++; Also: By returning a reference, the result may be used as an lvalue. (i++) = something else; If used on the right hand side of an assignment i.e. j = i++, return by reference (almost) guarantees a copy of the object is not created in the process. Ed Schiebel AT&T Bell Laboratories att!vilya!dog