Consider the class below using the A () method, which contains two lambda functions, a1 () and a2 (). I would like to be able to call a2 from inside a1. However, when I do this (second line inside a1), I get an error
Error: the variable "cannot be implicitly committed because the default capture mode was not set"
I do not understand this error message. What should I collect here? I understand that using [this] in a lambda definition gives me access to the methods of the foo class, but I don’t understand how to do what I want.
Thanks in advance for being right on this.
class foo
{
void A()
{
auto a2 = [this]() -> int
{
return 1;
};
auto a1 = [this]() -> int
{
int result;
result = a2();
return result;
};
int i = a1();
int j = a2();
}
};
source
share