A lambda function is a type of anonymous function that allows you to define and use a function in-place, without the need to declare it separately. In this program, a lambda function is created to calculate the sum of two integers, which are passed as parameters to the function.
The auto keyword is used to automatically deduce the return type of the lambda function. In this case, the lambda function returns an integer, which is the result of adding the two parameters.
The sum variable is initialized with the lambda function, and then called with arguments 5 and 6. The result of the function is then printed to the console using cout.
//Lambda Expressions/Functions #include <iostream> using namespace std; int main() { auto sum =[](int a,int b) { return a+b; }; cout <<"Total :"<< sum(5, 6) << endl; return 0; }
Total :11To download raw file Click Here
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions