#include #include #include #include #include using namespace std ; int main() { //using the mutable keyword //we can change the value in the lambda function //but that change is not refected in the code calling //the lambda function int a1 = 1; int b1 = 1; cout << "In main():" << endl; cout << "a1 = " << a1 << ", "; cout << "b1 = " << b1 << endl; cout << endl; auto add_one = [a1, &b1] () mutable { // modify both a1 & b1 a1++; b1++; cout << "In add_one():" << endl; cout << "a1 = " << a1 << ", "; cout << "b1 = " << b1 << endl; }; add_one(); add_one(); cout << endl; cout << "In main() After calling the lambda function:" << endl; cout << "a1 = " << a1 << ", "; cout << "b1 = " << b1 << endl; }