1 #include <iostream> 2 #include <thread> 3 using namespace std; 4 5 //伪函数,可以将对象名当做函数来使用 6 struct func 7 { 8 func() 9 { 10 cout << "create "<< endl; 11 } 12 ~func() 13 { 14 cout << "destroy"<< endl; 15 } 16 void operator()() 17 { 18 cout << "hello" << endl; 19 } 20 21 void operator()(int i) 22 { 23 cout << "hello" << i << endl; 24 } 25 }; 26 27 void main() 28 { 29 //调用 30 func f1; 31 f1(); 32 f1(3); 33 //多线程 34 thread t1(f1); 35 cin.get(); 36 }