This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Member function using pointer to member function
- To: Volker Boerchers <boercher at physik dot uni-bremen dot de>, egcs at cygnus dot com
- Subject: Re: Member function using pointer to member function
- From: Timothy Ritchey <tritchey at vne dot com>
- Date: Mon, 14 Sep 1998 15:38:19 +0000
- Organization: Vacuum Genesis
- References: <Pine.LNX.3.96.980914125912.8493A-100000@hix.physik.uni-bremen.de>
- Reply-To: tritchey at vne dot com
> 13 double A::ff(double (A::*func)(double), double t)
> 14 {
> 15 return func(t);
> 16 }
> Who is wrong; what can i do to make it work?
int this case, I believe you need to tell it which instantiation you
want it to call the function for. you will find that this will compile
and run:
double A::ff(double (A::*func)(double), double t)
{
return (this->*func)(t);
}
notice the use of parenthises to deal with precedence. Anyway, the
pointer to member function is a reference to the function relative to
its object. As an analogy, imagine you are passing in an index to an
array - you still need to tell it which array you want it to deal with.
BTW this is not the case with static member functions, which act like
normal pointers to functions.
cheers,
tim