fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int sum(int x, int y)
  6. {
  7. return x + y;
  8. }
  9.  
  10. auto get_f(int x)
  11. {
  12. return [x](int y) { return sum(x, y); };
  13. }
  14.  
  15. int main()
  16. {
  17. auto f = get_f(10);
  18. int x = f(3);
  19. cout << x << endl;
  20.  
  21. return 0;
  22. }
Success #stdin #stdout 0s 4416KB
stdin
Standard input is empty
stdout
13