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:

Get hands-on with 1400+ tech skills courses.