1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 《一秒学会C++》异步回调函数(C++11)

《一秒学会C++》异步回调函数(C++11)

时间:2023-01-05 18:13:21

相关推荐

《一秒学会C++》异步回调函数(C++11)

创建文件,复制C++代码,执行下面的命令

g++ -std=c++11 -o async_test -lpthread

#include <future>#include <iostream>#include <string>#include <functional>void func(std::string str){if (pare("Hello World 1") == 0){char pause = getchar(); // 按回车显示}std::cout << str << std::endl;}void Print(std::function< void(std::string)> Functional){auto a = std::async(std::launch::async, Functional, "Hello World 1");auto b = std::async(std::launch::async, Functional, "Hello World 2");auto c = std::async(std::launch::async, Functional, "Hello World 3");}int main(){Print(func);return 0;}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。