首页 > 编程 > C++ > 正文

c++回调之利用sink示例

2020-01-26 15:33:24
字体:
来源:转载
供稿:网友

复制代码 代码如下:

// cbBysink.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "cbBysink.h"

/************************************************************************/
/*                上层回调函数                                            */
/************************************************************************/

class CMyWork : public baseCallBack
{
public:
    CMyWork()
    {
        // 注册回调
        CWork::registercallback(this);
    }
    // 回调注册实现
    void CallbackFunction(int a, int b)
    {
        cout << "a = " << a << ",b = " << b << "/n" << endl;
        return;
    }
    // 触发回调
    void makefunction(int a, int b)
    {
        CWork::makecallback(a, b);
        return;
    }
protected:
private:
};

int main(int argc, char* argv[])
{
    CMyWork c_mywork;

    // 触发的时候不需要进行动态注册
    c_mywork.makefunction(5, 6);

    return 0;
}

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表