c++ - How create a function pointer to point a member function? -
this question has answer here:
- function pointer class member 2 answers
code:
struct { void* f(void *) { } }; int main() { void * (*fp)(void *); fp = &a::f; }
compile:
|12|error: cannot convert 'void* (a::*)(void*)' 'void* (*)(void*)' in assignment|
i have tried many ways, failed... how that?
for regular member pointer, you'll need declare type it's member of on pointer type;
int main() { void * (a::*fp)(void *); fp = &a::f; }
Comments
Post a Comment