I would like to pass a function pointer along with type fnptr_t. However it is a member of Box class. When I compile this code I get this error. What does this mean and how can I fix it?
#include <iostream>
using namespace std;
struct direction{
int i;
};
typedef void (*fnptr_t)(struct direction *);
class Box
{
public:
Box(int size = 3);
~Box(void);
void fall(struct direction *d){printf("fnptr\n");}
};
int main()
{
/* main.cpp:26*/ fnptr_t ptr = &Box::fall;
}
Error:
main.cpp:26:26: error: cannot convert 'void (Box::*)(direction*)' to 'fnptr_t {aka void (*)(direction*)}' in initialization
fnptr_t ptr = &Box::fall;