What is the role of the return statement in a lambda function?
- To indicate the end of the lambda function.
- To return a value from the lambda to the calling function.
- It determines the type of the lambda.
- It can't be used in lambda functions.
Lambda functions, like regular functions, can return values. If the lambda's body contains more than one statement, a return statement can be used to specify which value is returned. If the lambda's body consists of a single return statement, the return type is automatically inferred by the compiler.
Loading...
Related Quiz
- Can a friend function of a class access the private members of that class?
- In C++, an abstract class can have a mix of abstract as well as _______ methods.
- The conditions in a switch-case statement must be of _______ data type.
- Which of the following data types is not a primitive data type in C++?
- In C++, _______ functions cannot be virtual.