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

  1. Path: sparky!uunet!charon.amdahl.com!netcomsv!netcomsv!ulogic!hartman
  2. From: hartman@ulogic.UUCP (Richard M. Hartman)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: References to functions?
  5. Message-ID: <928@ulogic.UUCP>
  6. Date: 27 Jan 93 19:28:38 GMT
  7. References: <1993Jan21.044013.1429@athena.mit.edu> <1993Jan21.173352.10406@taumet.com>
  8. Organization: negligable
  9. Lines: 30
  10.  
  11. In article <1993Jan21.173352.10406@taumet.com> steve@taumet.com (Steve Clamage) writes:
  12. >fritz@mtl.mit.edu (Frederick Herrmann) writes:
  13. >
  14. >>I tried to declare a reference to a function, but found that g++
  15. >>wouldn't let me.  After scanning ch. 8 of the ARM, I interpret it to
  16. >>forbid function references, but it's not all that clear (see below).
  17. >
  18. >References to functions are legal, but not very useful.  I can't
  19. >think of anything you can do with a reference to a function you
  20. >can't do with a const pointer to a function in exactly the same way,
  21. >except for trivial syntax differences at the point of initialization.
  22. >You use them in exactly the same way.
  23.  
  24. There is one big difference between pointers & references, whether
  25. we are discussing functions or just data.
  26.  
  27. A pointer may be uninitialized, or NULL, and cannot be used safely
  28. without testing.
  29.  
  30. A reference is guaranteed to be initialized.
  31.  
  32. Aside from the notational convenience, this guarantee can make some 
  33. code more efficient.
  34.  
  35. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  36. Did you think it's a joke?        |
  37. Well that's all right, do what         |    -Richard Hartman
  38. you want to do.                |    hartman@uLogic.COM
  39. I've said my piece, now I         |
  40. leave it all up to you.            |
  41.