home *** CD-ROM | disk | FTP | other *** search
- 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
- From: KOCHER@nvdv.e-technik.uni-stuttgart.dbp.de (HARTMUT KOCHER)
- Newsgroups: comp.lang.c++
- Subject: Re: References to functions?
- Date: 25 Jan 1993 09:49:33 GMT
- Organization: University of Stuttgart, IND (Germany)
- Lines: 28
- Distribution: world
- Message-ID: <1k0d3dINNev9@info2.rus.uni-stuttgart.de>
- References: <1993Jan21.044013.1429@athena.mit.edu> <1993Jan21.173352.10406@taumet.com>
- NNTP-Posting-Host: nvdv01.ind.e-technik.uni-stuttgart.de
- X-News-Reader: VMS NEWS 1.24
- In-Reply-To: steve@taumet.com's message of Thu, 21 Jan 1993 17:33:52 GMT
-
- In <1993Jan21.173352.10406@taumet.com> steve@taumet.com writes:
-
- > fritz@mtl.mit.edu (Frederick Herrmann) writes:
- >
- > >I tried to declare a reference to a function, but found that g++
- > >wouldn't let me. After scanning ch. 8 of the ARM, I interpret it to
- > >forbid function references, but it's not all that clear (see below).
- >
- > References to functions are legal, but not very useful. I can't
- > think of anything you can do with a reference to a function you
- > can't do with a const pointer to a function in exactly the same way,
- > except for trivial syntax differences at the point of initialization.
- > You use them in exactly the same way.
- >
- > stuff deleted
- --
- >
- > Steve Clamage, TauMetric Corp, steve@taumet.com
-
- Not exactly. Let's say I have a callback class which takes a pointer
- to a function in its constructor. If I use a pointer, a 0-pointer may be
- passed. If I use a reference instead, I can make sure, that the user
- supplies a valid function.
-
- B.T.W.: Are references to member functions also legal?
-
- Hartmut Kocher
-
-