home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / cplus / 19913 < prev    next >
Encoding:
Text File  |  1993-01-26  |  1.6 KB  |  40 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fjh
  3. From: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
  4. Subject: Re: Overloading Operators
  5. Message-ID: <9302623.13017@mulga.cs.mu.OZ.AU>
  6. Sender: news@cs.mu.OZ.AU
  7. Organization: Computer Science, University of Melbourne, Australia
  8. References: <C0tH6M.FrM@cs.uiuc.edu> <1993Jan13.150525.20916@mobil.com> <727392166snx@trmphrst.demon.co.uk> <C13BK9.Lr@frumious.uucp> <2215@celia.UUCP>
  9. Date: Tue, 26 Jan 1993 12:08:25 GMT
  10. Lines: 28
  11.  
  12. gray@celia.UUCP (Steve Gray) writes:
  13.  
  14. >> Like Nikki, I can't think of any way in which a const or volatile
  15. >> reference differs from a plain reference.  Is there a difference?
  16. >
  17. >A const reference differs in a very important way from a plain reference:
  18. >it clearly states that the member function has no side effects.
  19.  
  20. The term "const reference" was being used in this thread to indicate
  21.     int & const ref
  22. not
  23.     const int & ref
  24. So it doesn't indicate that the object referred to is not changed.
  25.  
  26. I agree with the earlier statements that const references don't differ from
  27. plain references. But I can see that a volatile reference might differ from
  28. a plain reference, although I see no useful way of using this difference.
  29.  
  30.     int i;
  31.     int & volatile ref = i;        // 'volatile' here prevents compiler
  32.                     // from optimizing away 'ref' if
  33.                     // it is not used?
  34.  
  35. -- 
  36. Fergus Henderson             fjh@munta.cs.mu.OZ.AU      
  37. This .signature virus is a self-referential statement that is true - but 
  38. you will only be able to consistently believe it if you copy it to your own
  39. .signature file!
  40.