Problems with pointer-to-members

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

 



Hi, I'm having a problem with gcc that is making me going nuts!

The compiler is not accepting the code below. I really don't see a light at the end of the tunnel, so, please someone help me...

Here is the code:

====================================== CLASS foo
class foo
{
public:
typedef void (foo::*ReadCallback)(char * buffer, unsigned int size);

protected:
void DoAnything(ReadCallback method);
virtual void WhenComplete(char * buffer, unsigned int size);
};


====================================== CLASS foo2

class foo2 : public foo
{
private:
void DoSomething();
};

====================================== foo DECLARATIONS

void foo::DoAnything(ReadCallback method)
{
//do something with the method
}

void foo::WhenComplete(char * buffer, unsigned int size)
{
throw "Please overload this method!!";
}

====================================== foo2 DECLARATIONS

void foo2::foo::WhenComplete(char * buffer, unsigned int size)
{
//do something
};


//Here comes the annoying error

void foo2::DoSomething()
{
ReadCallback callback = WhenComplete;
DoAnything(callback);
}


Here goes the error:
"argument of type ‘void (foo::)(char*, unsigned int)’ does not match ‘void(foo::*)(char*, unsigned int) "


then, I tryed this:

void foo2::DoSomething()
{
ReadCallback callback = &WhenComplete;
DoAnything(callback);
}

and got this:

"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’"



So, anyone could light my path on this?

Thanks in advance,

Guilherme Müller



[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