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

  1. Path: sparky!uunet!cs.utexas.edu!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!usenet.coe.montana.edu!news.u.washington.edu!sumax.seattleu.edu!thebes!manutius!garyp
  2. From: garyp@manutius.UUCP (Gary Powell)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Reference vs. Pointer
  5. Message-ID: <731@manutius.UUCP>
  6. Date: 21 Jan 93 17:37:18 GMT
  7. References: <1993Jan15.175541.247@base> <1993Jan17.232403.5936@microsoft.com>
  8. Reply-To: garyp@manutius (Gary Powell)
  9. Distribution: na
  10. Organization: Aldus Corporation, Seattle WA
  11. Lines: 39
  12.  
  13.  
  14. One other thing references do well is when you are overloading operators
  15. and attempting you can give oject symantics while not putting objects on the
  16. stack. ie:
  17.  
  18. class foo {
  19.     public:
  20.     friend foo &operator/(foo &lhs,foo &rhs);
  21.     // rest of definition....
  22. }
  23.  
  24. foo & operator/(foo &lhs, foo &rhs)
  25. {
  26.     foo result;
  27.  
  28.     // Do result = lhs/rhs;
  29.  
  30.     .
  31.     .
  32.     .
  33.     return result;
  34. }
  35.  
  36. Which allows you to write;
  37.  
  38.    foo a,b(inital value),c(initial value);
  39.  
  40.    a = b/c;
  41.  
  42. }
  43.  
  44. PS.
  45.   Be sure and write the copy constructor, and overload the assignment operator
  46.   too.
  47. Gary Powell ------------+ Internet:     garyp@aldus.com
  48. c/o Aldus Corporation   | uunet:        manutius!garyp@uunet.uu.net
  49. 411 1st Ave South       | uucp:         camco!manutius!garyp
  50. Seattle, WA 98104  USA  | Voice:        (206) 622-5500
  51.