32.成员函数与多线程
1 #define _CRT_SECURE_NO_WARNINGS 2 #include <iostream> 3 #include <thread> 4 #include <Windows.h> 5 using namespace std; 6 7 class fun 8 { 9 public: 10 char str[100]; 11 public: 12 fun(char *str) 13 { 14 strcpy(this->str, str); 15 } 16 17 void run() 18 { 19 MessageBoxA(0, str, "324", 0); 20 cout << "hello" << endl; 21 } 22 }; 23 24 void main() 25 { 26 fun fun1("hello"); 27 fun fun2("你好"); 28 thread th(&fun::run, fun1); 29 thread th2(&fun::run, fun2); 30 cin.get(); 31 }