Suppose that I have a class that accepts a function pointer in its constructor like this:
class IOControl
{
public:
IOControl(void (*callback)(void));
};
And I have another class that I want to pass a non-static member address of it to above class constructor:
class Core
{
public:
Core();
private:
void some_callback();
IOControl io;
};
Core::Core(): io(&Core::some_callback)
{
}
But I get this error:
no matching function for call to 'IOControl::IOControl(void (Core::*)())'
If I make both io
and some_callback
as static it would work fine but as a non-static member, I get the above error.
Also using Core::Core(): io(&(this->some_callback))
or Core::Core(): io(&some_callback)
give me ISO C++ forbids taking the address of an unqualified or parenthesized non-static member function...
error.