/* File: lambda2.cpp Simple example of returning a lambda expression using auto. "auto" is C++'s type inferencing. */ #include using namespace std ; auto makeAddXLambda(int x) { return [=](int n){ return n + x ; } ; // = means capture all by value } int main () { auto add3 = makeAddXLambda(3) ; cout << "add3(5) = " << add3(5) << endl ; auto add5 = makeAddXLambda(5) ; cout << "add5(8) = " << add5(8) << endl ; }