C++ FunctionsLesson 30Free preview
C++ Lambda
This lesson is part of C++ · All levels
Summary
This lesson discusses lambda expression, an anonymous function that can be defined directly within an expression without the need for a separate declaration. Lambda is very practical for a short function that is only used once, for example as an algorithm argument. You study the parts of the lambda: capture, parameters, type, and body functions.
Key points
- The basic shape of the lambda: [capture]
- Capture determines the external variables that can be accessed within the lambda.
- Lambda is often stored on a variable with the type auto.
- Lambda without capture can be converted to a normal pointer function.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.