C++的回调函数定义方法使用了无数次,就是记不住。。。这里再copy一次:
typedef int (*callback)(int param1, char* param2); Syntax typedef return_code (*function_virtual_name)(parameters list); Example class CCall; typedef int (*callback)(CCall* call, int i); class CCall{ public: CCall(int i = 0) : _i(i) {}; virtual ~CCall() {} int becall(int i) { return call(i); } virtual int call(int i) = 0; private: int _i; }; static int Func(CCall* call, int i) { return call->becall(i); }
|
阅读(1788) | 评论(0) | 转发(0) |