What this C++ lambda-capture interview question tests
This is an easy question on C++ language fundamentals, specifically how lambda functions handle variable capture and default argument semantics. It's the kind of thing interviewers ask to quickly filter for candidates who have hands-on experience with modern C++ rather than just book knowledge.
The question asks you to reason carefully about what happens when a lambda is defined, what variables it has access to, and what the actual behaviour is when the code runs. It rewards close attention to syntax and the distinction between different capture mechanisms.
- Lambda capture modes (by value vs. by reference)
- Variable scope and lifetime in lambda contexts
- Default arguments and when they are evaluated