C++11 introduced lambda expression to allow us write a function not worth naming.
A lambda can introduce new variables in its body (in C++14), and it can also access, or capture, variables from the surrounding scope.
A lambda begins with the capture clause. It specifies which variables are captured, and whether the capture is by value or by reference. Variables that have the ampersand (&) prefix are accessed by reference and variables that don't have it are accessed by value.
You can use a capture-default mode to indicate how to capture any outside variables referenced in the lambda body:
* [&] means all variables that you refer to are captured by reference,
* [=] means they're captured by value.
* An empty capture clause, [], indicates that the body of the lambda expression accesses no variables in the enclosing scope.
```
#include <iostream>
using namespace std;
int main() {
auto square = [](int i) { return i * i; };
cout << "Square of 5 is : " << square(5) << endl;
}
```