fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. auto makeAdd(int x) {
  5. return [x](int i) { return x + i; };
  6. }
  7.  
  8. int main() {
  9. int i = 7; // or from cin
  10. auto add = makeAdd(i);
  11. int result = add(888);
  12. cout << "add(888) = " << result;
  13. return 0;
  14. }
Success #stdin #stdout 0s 4368KB
stdin
Standard input is empty
stdout
add(888) = 895