This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Pointer-to-member usage?


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.



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