Normally such a callback would look like this:
void Callback( void* data)
{
CMyClass *myClassInstance = static_cast<CMyClass *>(data);
myClassInstance->MyInstanceMethod();
}
Of course, you need to make sure, data points to an instance of your class. E.g.
CMyClass* data = new CMyClass();
FunctionCallingMyCallback( data, &Callback);
delete data;
Now, if I understand you correctly, you need to also pass a char*.
You can either wrap both in a struct and unwrap it in the callback like so:
MyStruct* data = new MyStruct();
data->PtrToMyClass = new CMyClass();
data->MyCharPtr = "test";
FunctionCallingMyCallback( data, &Callback);
delete data->PtrToMyClass;
delete data;
void Callback( void* data)
{
MyStruct *myStructInstance = static_cast<MyStruct *>(data);
CMyClass *myClassInstance = myStructInstance->PtrToMyClass;
char * myData = myStructInstance->MyCharPtr;
myClassInstance->MyInstanceMethod(myData);
}
or, if you can modify the definition of CMyClass, put all the necessary data in class members, so that you can use a callback as in the first example.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…