This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: C++ member function pointers in ISO C++
- To: Terry Barnaby <terry at beam dot demon dot co dot uk>
- Subject: Re: C++ member function pointers in ISO C++
- From: Fergus Henderson <fjh at cs dot mu dot oz dot au>
- Date: Fri, 12 Jan 2001 00:43:06 +1100
- Cc: gcc at gcc dot gnu dot org
- References: <3A5DB173.337F83C8@beam.demon.co.uk>
On 11-Jan-2001, Terry Barnaby <terry@beam.demon.co.uk> wrote:
> We are trying to compile some library code that passes the address of an
> objects member
> function together with the objects address to be used in a call-back
> method. Having upgraded
> to GCC 2.96 we now get a compilation error " ISO C++ forbids taking the
> address of a
> non-static member function to form a pointer to member function. Say
> `&A::Func1'"
>
> Questions:
> 1. Is there a proper way in ISO C++ of passing and storing a pointer to
> a member function ?
Yes. I think what the error message is trying to say is just that you
need to use the syntax `&ClassName::FuncName' rather than the more
concise but not standard-conforming `&FuncName'.
--
Fergus Henderson <fjh@cs.mu.oz.au> | "I have always known that the pursuit
| of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.