#include <iostream> using namespace std; int main(){ int a = 10; auto func1 = [=](int b){return a +b+ 1;}; auto func2 = [&](int b,int c){return a+b+c + 1;}; cout << func1(1) << endl; cout << func2(1,2) << endl; a++; cout << func1(1) << endl; cout << func2(1,2) << endl; return 0; }
原文: https://blog.csdn.net/iloveyousunna/article/details/78532398