home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!charon.amdahl.com!netcomsv!netcomsv!ulogic!hartman
- From: hartman@ulogic.UUCP (Richard M. Hartman)
- Newsgroups: comp.lang.c++
- Subject: Re: References to functions?
- Message-ID: <928@ulogic.UUCP>
- Date: 27 Jan 93 19:28:38 GMT
- References: <1993Jan21.044013.1429@athena.mit.edu> <1993Jan21.173352.10406@taumet.com>
- Organization: negligable
- Lines: 30
-
- In article <1993Jan21.173352.10406@taumet.com> steve@taumet.com (Steve Clamage) 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.
-
- There is one big difference between pointers & references, whether
- we are discussing functions or just data.
-
- A pointer may be uninitialized, or NULL, and cannot be used safely
- without testing.
-
- A reference is guaranteed to be initialized.
-
- Aside from the notational convenience, this guarantee can make some
- code more efficient.
-
- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- Did you think it's a joke? |
- Well that's all right, do what | -Richard Hartman
- you want to do. | hartman@uLogic.COM
- I've said my piece, now I |
- leave it all up to you. |
-