C++ examples for STL:Lambda
A recursive lambda expression
#include <iostream> #include <functional> int main()/*from ww w .ja va 2s . c o m*/ { std::function<int(int)> reverseNumber {[&reverseNumber](int no) -> int { static int r {}; if (0 == no) return r; else r = r * 10 + no % 10; return reverseNumber(no / 10); }}; int nn {12345}, r {}; std::cout << nn << " " << reverseNumber(nn) << std::endl; }