1 #include <iostream> 2 #include <functional> 3 using namespace std; 4 5 void main() 6 { 7 //&调用外部 8 //function<void(void)> fun = [&]()->void {cout << "hello" << endl; fun(); }; 9 function<void(int)> fun = [&](int i) 10 { 11 if (i == 0) 12 { 13 return 0; 14 } 15 else 16 { 17 cout << i << endl; 18 fun(i-1); 19 } 20 }; 21 fun(100); 22 system("pause"); 23 }