3、复制并引用捕获
#include
usingnamespace std;
int main()
{
int i =1024, j =2048;
cout <<"i:"<<&i << endl;
cout <<"j:"<<&j << endl;
auto fun1 =[=,&i]{// 默认拷贝外部所有变量,但引用变量 i
cout <<"i:"<<&i << endl;
cout <<"j:"<<&j << endl;
};
fun1();
}
3、复制并引用捕获
#include
usingnamespace std;
int main()
{
int i =1024, j =2048;
cout <<"i:"<<&i << endl;
cout <<"j:"<<&j << endl;
auto fun1 =[=,&i]{// 默认拷贝外部所有变量,但引用变量 i
cout <<"i:"<<&i << endl;
cout <<"j:"<<&j << endl;
};
fun1();
}