home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / cplus / 19868 < prev    next >
Encoding:
Internet Message Format  |  1993-01-25  |  1.2 KB

  1. Path: sparky!uunet!usc!celia!gray
  2. From: gray@celia.UUCP (Steve Gray)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Overloading Operators
  5. Message-ID: <2215@celia.UUCP>
  6. Date: 24 Jan 93 00:07:56 GMT
  7. References: <C0tH6M.FrM@cs.uiuc.edu> <1993Jan13.150525.20916@mobil.com> <727392166snx@trmphrst.demon.co.uk> <C13BK9.Lr@frumious.uucp>
  8. Reply-To: celia!gray@usc.edu (Steve Gray)
  9. Organization: Rhythm & Hues, Inc., Hollywood
  10. Lines: 14
  11.  
  12. > Like Nikki, I can't think of any way in which a const or volatile
  13. > reference differs from a plain reference.  Is there a difference?
  14.  
  15. A const reference differs in a very important way from a plain reference:
  16. it clearly states that the member function has no side effects.  One of
  17. my (and others at R&H's) primary objections to using references is that
  18. it means member functions can have un-obvious side effects on their parameters. 
  19. i.e. they can change the contents of a variable which was passed by value (as 
  20. far as the caller's syntax is concerned) and therefor should not be changed by 
  21. the member function.
  22.  
  23. We have basically outlawed non-const references as being too dangerous.  I
  24. personally would have preferred that they not even be allowed in the language,
  25. but I can understand why (given the syntax of the language) they are allowed.
  26.