This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Pointer-to-member usage?
- From: Paolo Carlini <pcarlini at unitus dot it>
- To: Stefan Olsson <stefan at noname4us dot com>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Mon, 07 Jan 2002 21:48:03 +0100
- Subject: Re: Pointer-to-member usage?
- References: <3C39AC80.6628CCB8@noname4us.com>
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.