要有一個結構:調用對象的方法(MSVC2010)
scheduled_call {
MyClass* object;
int value;
void (MyClass::*setter)(const int)
}
對於類:
MyClass {
void doSomething(const int);
}
結構編譯所有好,但是當我嘗試調用值的功能,它會拋出錯誤:
我需要執行保存在此結構中的調用。我嘗試這樣做:
void executeIt(scheduled_call cl) {
cl.object->*(cl.method)(cl.value);
}
,但我得到:
error C2064: term does not evaluate to a function taking 1 arguments
我的編碼是基於C/C++ function pointer guide。我正在做這個作爲一個實驗,如果失敗,我可以回到switch
當然聲明。
任何人都可以在Visual Studio 2010下編譯這個嗎?
本帖](http://stackoverflow.com/questions/6262712/c-member-function-pointer-問題)(第二個答案具體)是成員函數指針語法的一個很好的參考。 – Carlton