This is the mail archive of the egcs@egcs.cygnus.com mailing list for the EGCS project. See the EGCS home page for more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Ptrs to functions (gcc vs. egcs)




Bob McWhirter wrote:
> 
> On Sat, 27 Mar 1999, Mike wrote:
> 
> > On 27 Mar 1999, Jason Merrill wrote:
> >
> > > Just change
> > >
> > >   ptr();
> > >
> > > to
> > >
> > >   this->*ptr();
> > >
> > > Jason
> > >
> >
> > This doesn't seem to fix it. Same error message results.
> 
> I've tended to us:
> 
>         this->(*ptr)();
> 
> Which might or might not work for you.
> 
>         -B

The C++-Faq lite[1] told me to use 

  (this->*ptr)();

or

  ((*this).*ptr)();

In fact, they propose defining a macro to make the call look cleaner [2] :

  #define callMemberFunction(object,ptrToMember)  ((object).*(ptrToMember)) 

  callMemberFunction(*this, ptr)();

Greetings,

Jeroen Dobbelaere

[1] <http://www.informatik.uni-konstanz.de/~kuehl/cpp/cppfaq.htm/>
[2] <http://www.informatik.uni-konstanz.de/~kuehl/cpp/cppfaq.htm/pointers-to-members.html>