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

  1. Path: sparky!uunet!usc!howland.reston.ans.net!spool.mu.edu!yale.edu!ira.uka.de!news.belwue.de!news.uni-stuttgart.de!news.uni-stuttgart.de!news
  2. From: KOCHER@nvdv.e-technik.uni-stuttgart.dbp.de (HARTMUT KOCHER)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: References to functions?
  5. Date: 25 Jan 1993 09:49:33 GMT
  6. Organization: University of Stuttgart, IND (Germany)
  7. Lines: 28
  8. Distribution: world
  9. Message-ID: <1k0d3dINNev9@info2.rus.uni-stuttgart.de>
  10. References: <1993Jan21.044013.1429@athena.mit.edu> <1993Jan21.173352.10406@taumet.com>
  11. NNTP-Posting-Host: nvdv01.ind.e-technik.uni-stuttgart.de
  12. X-News-Reader: VMS NEWS 1.24
  13. In-Reply-To: steve@taumet.com's message of Thu, 21 Jan 1993 17:33:52 GMT
  14.  
  15. In <1993Jan21.173352.10406@taumet.com> steve@taumet.com writes:
  16.  
  17. > fritz@mtl.mit.edu (Frederick Herrmann) writes:
  18. > >I tried to declare a reference to a function, but found that g++
  19. > >wouldn't let me.  After scanning ch. 8 of the ARM, I interpret it to
  20. > >forbid function references, but it's not all that clear (see below).
  21. > References to functions are legal, but not very useful.  I can't
  22. > think of anything you can do with a reference to a function you
  23. > can't do with a const pointer to a function in exactly the same way,
  24. > except for trivial syntax differences at the point of initialization.
  25. > You use them in exactly the same way.
  26. > stuff deleted
  27. -- 
  28. > Steve Clamage, TauMetric Corp, steve@taumet.com
  29.  
  30. Not exactly. Let's say I have a callback class which takes a pointer
  31. to a function in its constructor. If I use a pointer, a 0-pointer may be
  32. passed. If I use a reference instead, I can make sure, that the user
  33. supplies a valid function.
  34.  
  35. B.T.W.: Are references to member functions also legal?
  36.  
  37. Hartmut Kocher
  38.  
  39.