c++ call back function

#include <functional>

#include <iostream>

using std::function;

using callBack = function<void()>;

using std::cout;

using std::endl;

void f1( int a) 

{

cout << "f1 a is" << a << endl;

}

void call(callBack f)

{

    f();

}

int main(int argc,char** argv)

{

    callBack f = std::bind(&f1,1);

    call(f);

    return 0;

}

猜你喜欢

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