5、捕获this指针
#include
usingnamespace std;
class test
{
public:
void hello(){
cout <<"test hello!n";
};
voidlambda(){
auto fun =[this]{// 捕获了 this 指针
this->hello();// 这里 this 调用的就是 class test 的对象了
};
fun();
}
};
int main()
{
test t;
t.lambda();
}