C++之三种callbcak方式

#include <iostream>
#include <string>
#include <pthread.h>
#include <functional>
using namespace std;
typedef void (*MyFun)(int n, string str);

static void Test(int n, string str){
  cout << "n = "<< n << " str = " << str <<endl;
}

typedef std::function <void(int n, string str)> m1;

int main(){
	MyFun m1;

	//callback 1
	m1 = Test;	
	m1(111,"1233" );

	//callback 2
	auto func3 = std::bind(Test, std::placeholders::_1, std::placeholders::_2);
	func3(2222, "Hello");


	//callback 3
	m1 = Test;	
	cc(44444,"mmmmmm");
	
	return 0;
}

上一篇:ES6的模块化


下一篇:Photoshop 2021 M1原生版没有扩展面板怎么办,ps 2021 m1版无法使用旧版插件