回调 两种不同的使用方式

#include <functional>

#include <iostream>

// one method

using callback = std::function<void()>;

// another method

//typedef std::function<void()> callback;

void f1()

{

    std::cout << "a" << std::endl;

}

void call(callback f)

{

    f();

}

int main(int argc,char** argv)

{

    callback c1 = std::bind(&f1);

    call(c1);

    return 0;


}

猜你喜欢

转载自blog.csdn.net/slwrq/article/details/79620259