f



lamda's in classes

if you make a lamda with a method from a class, can that method see the
valuable values encapsulated with the object of that class, or can it
only see global variables?
0
ruben
12/21/2016 9:09:51 AM
comp.lang.c++ 49423 articles. 7 followers. Post Follow

2 Replies
572 Views

Similar Articles

[PageSpeed] 8

On 21.12.2016 10:09, ruben safir wrote:
> if you make a lamda with a method from a class, can that method see the
> valuable values encapsulated with the object of that class, or can it
> only see global variables?
>

To use non-static data members in a lambda in a class' code, you have to 
capture `this`.

Cheers & hth.,

- Alf

0
Alf
12/21/2016 12:27:56 PM
On Wednesday, December 21, 2016 at 4:28:13 AM UTC-8, Alf P. Steinbach wrote:
> On 21.12.2016 10:09, ruben safir wrote:
> > if you make a lamda with a method from a class, can that method see the
> > valuable values encapsulated with the object of that class, or can it
> > only see global variables?
> >
> 
> To use non-static data members in a lambda in a class' code, you have to 
> capture `this`.
> 
> Cheers & hth.,
> 
> - Alf

Alf,

I want to congratulation you on understanding the question. Seeing your answer, I think you figured out the question and answered it correctly.

When I read the question, I had no idea what was being asked. I think the "valuable values" threw me most.

Jon
0
jonkalb
12/21/2016 11:45:48 PM
Reply: