fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int i=1;
  6. auto add = [&](int x) {i=2;return x+i;};
  7. cout << add(3)<<endl;
  8. cout << i;
  9. return 0;
  10. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
5
2