c++ - How create a function pointer to point a member function? -


this question has answer here:

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

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

java - SmsManager sending message more than one -