c++回调函数

C++使用回调函数的一种方法如下:

Example::Example() {}

Example::~Example() {}

int Example::Start() {
    auto callback = [this](const int type)->int {
        this->Callback(type);
        return 0;
    };

    xxx.ReginsterCallback(callback);
    return 0;
}

int Example::Callback(const int type) {
    /* do sth */
}

int main(int argc, char* argv) {
    Example ex;
    ex.Start();
}
原文地址:https://www.cnblogs.com/cfox/p/7754856.html