...

/

Initializing Variables in Capture

Initializing Variables in Capture

Explore the initialization of variables in the capture and member variables initialization inside a lambda.

Member variables initialization inside a lambda

As seen in the previous lesson, the capture clause initializes member variables in the corresponding class. This means that we can also initialize member variables inside a lambda. These variables will only be visible from inside the lambda. Here is an example of a lambda that initializes a capture variable called numbers:

Access this course and 1400+ top-rated courses and projects.