Re: Problems with pointer-to-members

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I don't remember the answer from the last time I did something similar (different compiler anyway) and don't have time to test now.

But the error message you quoted tells you exactly what to do to fix the problem. Have you tried doing what it tells you?

Guilherme Müller wrote:

class foo2 : public foo

...

ReadCallback callback = &WhenComplete;

...

"ISO C++ forbids taking the address of an unqualified or parenthesized non-static member function to form a pointer to member function. Say ‘&foo::WhenComplete’"
Maybe you want
ReadCallback callback = &foo2::WhenComplete;

I understand that foo2 doesn't actually have a WhenComplete, but that doesn't normally matter.

I'm also unsure of what that means between two possibilities and unsure of what you want it to mean between three possibilities.

A) At compile time trace the inheritance up from the calling code ( foo2::DoSomething() ) to find the first version of WhenComplete

B) Compiler creates an intermediate routine, so callback becomes the address of the intermediate routine, and when the callback is used later, the intermediate routine will select the (then) correct WhenComplete from the object on which the callback is used.

C) At run time in foo2::DoSomething() select the WhenComplete from the (then) current object, which might be something derived from foo2.

My best guess is both the compiler and you agree on meaning B. But I'm not sure of either.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux