C++ register callback from server -
i've prototype of callback as:
typedef void (*update)(int id,...); typedef void (*destroy)(int id,...); typedef void (*create)(int id, update* _update, destroy* _destroy); and create callbacks function:
void updatecb(int id,...){/*add id collection*/} void destroycb(int id,...){/*remove id collection*/} void createcb(int id,update* _update, destroy* _destroy) { //register callbacks *_update = updatecb; *_destroy = destroycb; } when register callbacks compiler give me error:
error: cannot convert 'classname::updatecb' type 'void (classname::)(int,...)' type 'update {aka void (*)(int..)}'
how can valid register callbacks?
you trying use member functions impossible in case. happens because every member function ( if not static ) carries hidden pointer class instance called this. need use global functions or static member functions.
Comments
Post a Comment