Hi, non-static member functions needs the this pointer. You cannot call them without an object. On Monday 09 June 2003 10:43, Verdi March wrote:
Hi,
I'm creating a C++ wrapper to API written in C. One of the C function takes a pointer to function as an argument: cfunction(int (*callback)(int, *char[]));
The wrapper uses a pure virtual function: class Process { public: virtual int run(int i, *char[]) = 0;
static int runCaller( Process* obj, int i, char** v) { return obj->run( i, v); }
};
Pointers to static member functions are like C-function pointers.
Problem is, how to "convert" run to "callback"? I've tried cfunction(&Process::run), but g++ keeps complaining:
cannot convert `int (Process::*)(int, char**)' to `int (*)(int, char**)' for argument `2' to `s_m_process* MSG_process_create(const char*, int (*)(int, char**), void*, s_m_host*)'