以我的C++程序,我需要调用该C API:如何传递一个C++成员函数的C API作为参数
GConn* gnet_conn_new (const gchar *hostname,
gint port,
GConnFunc func);
其中GConnFunc定义为:
void (*GConnFunc) (GConn *conn);
我的问题是,如果我有一个C++类,并有一个成员函数,如:
Class A {
public:
A();
void my_func (GConn* conn);
}
在我A::A()
构造函数,我怎么能传递this->myfunc
到gnet_conn_new
作为GConnFunc
参数?
谢谢。
建议的重复(http://stackoverflow.com/questions/130322/how-do-you-pass-a-member-function-pointer)不*看起来是重复的。它讨论了在所有C++上下文中传递指向成员的指针。 – dmckee 2010-03-25 17:30:18