C++ lambda expressions can capture their surrounding scope variables either by value (=) or by reference(&). You can use the lambda capture clause - square brackets [ ] - to indicate which variables need to be captured and how (value or reference). For an introduction to lambda expressions read "Lambda Expressions in C++".
This code captures an array by value in a lambda, modifies the array after the definition of lambda, and then calls that lambda function:
// create and initialize array with all 0s
int collection[5] = {};
// capture collection by value
auto process = [=]() {
for(int i : collection)
std::cout << i << " ";
};
// modify the array elements
for(int i=0; i < 5; ++i)
collection[i] = i;
// call lambda
process();
What do you think would be the output of calling process?