类成员函数定义:
int testClass::test()
{
auto getNum = [this](int a, int b){
return (a-b);
};
int c = getNum(5, 4);
return c;
}
这是一个lambda表达式,等价于:
int anonymous_function(int a, int b) { return (a-b); } auto getNum = anonymous_function;
并且捕获了this指针,可以在这个闭包函数中使用this。