# 08. C++ Lambda expression

Posted by Yulai Blog on November 8, 2015
1. Lambda expression
1
2
3
* An example lambda function is defined as follows:

*

1
2
* C++11 also supports closures. Closures are defined between square brackets [ and ] in the declaration of lambda expression.
* The mechanism allows these variables to be captured by value or by reference. The following table demonstrates this:

1
2
3
sum_1 = 15 sum_2 = 15
sum_1 = 15 sum_2 = 0
sum_1 = 0 sum_2 = 15