#include <iostream>
#include <functional>
using namespace std;
std::function<int(int)> makeAdd(int x) {
return [x](int i) { return x + i; };
}
void use(std::function<int(int)> f) {
int result = f(888);
cout << "f(888) = " << result;
}
int main() {
int i = 7; // or from cin
std::function<int(int)> add = makeAdd(i);
use(add);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8ZnVuY3Rpb25hbD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnN0ZDo6ZnVuY3Rpb248aW50KGludCk+IG1ha2VBZGQoaW50IHgpIHsKCXJldHVybiBbeF0oaW50IGkpIHsgcmV0dXJuIHggKyBpOyB9Owp9Cgp2b2lkIHVzZShzdGQ6OmZ1bmN0aW9uPGludChpbnQpPiBmKSB7CglpbnQgcmVzdWx0ID0gZig4ODgpOwoJY291dCA8PCAiZig4ODgpID0gIiA8PCByZXN1bHQ7Cn0KCmludCBtYWluKCkgewoJaW50IGkgPSA3OyAvLyBvciBmcm9tIGNpbgoJc3RkOjpmdW5jdGlvbjxpbnQoaW50KT4gYWRkID0gbWFrZUFkZChpKTsKCXVzZShhZGQpOwoJcmV0dXJuIDA7Cn0=