0
註冊回調我有回調的原型爲:C++從服務器
typedef void (*update)(int id,...);
typedef void (*destroy)(int id,...);
typedef void (*create)(int id, update* _update, destroy* _destroy);
而不是創建回調函數:
void updateCB(int id,...){/*Add id to collection*/}
void destroyCB(int id,...){/*Remove id from collection*/}
void createCB(int id,update* _update, destroy* _destroy)
{
//Register Callbacks
*_update = updateCB;
*_destroy = destroyCB;
}
當我註冊回調編譯器給我的錯誤:
error: cannot convert 'ClassName::updateCB' from type 'void (ClassName::)(int,...)' to type 'update {aka void (*)(int..)}'
我怎樣纔能有效的註冊回調?
函數指針與成員函數指針不相同。閱讀['std :: function'](http://en.cppreference.com/w/cpp/utility/functional/function)和['std :: bind'](http://en.cppreference.com/W/CPP /實用程序/功能/綁定)。 – 2013-05-03 10:29:23
關於成員的指針。 – Aneri 2013-05-03 10:29:57