fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. auto add(int x){
  5. auto fun = [x] (int y) { return x + y; };
  6. return fun;
  7. }
  8.  
  9. int main() {
  10. int x = 10;
  11. int y = 20;
  12. auto f = add(x);
  13. cout << f(y);
  14. return 0;
  15. }
Success #stdin #stdout 0s 4544KB
stdin
Standard input is empty
stdout
30