I was found general member function pointer call method.
buf that example is only void type.
I want to make general return type of method function call.
class Callback { public: void operator()() { call(); }; virtual void call() = 0; };
class BasicCallback : public Callback { // pointer to member function void (*function)(void);
public: BasicCallback(void(*_function)(void)) : function(_function) { }; virtual void call() { (*function)(); }; };
template class ClassCallback : public Callback { // pointer to member function void (AnyClass::function)(void); // pointer to object AnyClass object;
public: ClassCallback(AnyClass* _object, void (AnyClass::*_function)(void)) : object(_object), function(_function) { }; virtual void call() { (*object.*function)(); }; };
int MWAdaptorManager::appName(char* application) { string appS(application); if (ctl->appSetName(appS)) { cout << "[MWAdaptorManager::appName] OK : app.name=" << appS << endl; return 0; } else { cout << "[MWAdaptorManager::appName] Fail : app.name=" << appS << endl; return -1; } }
mwAdaptorMgr->m_middleAdapter->setCallback("appName", new ClassCallback(mwAdaptorMgr, &MWAdaptorManager::appName));
i cann't compile of that program.
Error 1 error C2664: 'ClassCallback::ClassCallback(AnyClass *,void (__thiscall MWAdaptorManager::* )(void))' : cannot convert parameter 2 from 'int (__thiscall MWAdaptorManager::* )(char *)' to 'void (__thiscall MWAdaptorManager::* )(void)' d:\RobotSW\ComponentEngine_src_1.0.20091012\src\system\ComponentEngine.cpp 131
What can i do?
Please answer to me~!