fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int X = 1;
  6.  
  7. auto worker = [=]() mutable {return X++;};
  8.  
  9. cout << worker() << endl;
  10. cout << worker() << endl;
  11. cout << worker() << endl;
  12. cout << worker() << endl;
  13.  
  14.  
  15. return 0;
  16. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
1
2
3
4