Pointer-to-member usage?

Paolo Carlini pcarlini@unitus.it
Mon Jan 7 12:48:00 GMT 2002


Stefan Olsson wrote:

> Hi!
>
> I am aware that this is not related to the development of libstdc++, but
> would appriciate input on what we are doing wrong here...

This is *really* off-topic!

However, I like learning more and more C++ and got very interested ;-) ...

>From C++SE, p. 419 I understand this: when you have available a pointer to
member, you still need a pointer to the class in order to be able to actually
call the member! Therefore your code should be reworked but the following scheme
works, combining with the syntax ...->*... the two needed pieces:

void B::UseFunctionPointer( int x, int y ) throw()
{
  A  a;
  A* pa = &a;

  (pa->*GetFunctionPointer())(x,y);
}

Cheers,
Paolo.




More information about the Libstdc++ mailing list