Lambda recognition: A lambda expression represents a callable unit of code that I can interpret as an unnamed inline function, a lambda with a return type, a parameter list, and a function body; a lambda may be defined inside a function.
Lambda expression: [Capture list] (parameter list)->return type{function body}
Exercise 10.14 Write a lambda, accept two int, return their and;
#include <iostream>usingnamespace std; int Main () { int a=5, b=6; = [] (intint &b) {return//lambda expression cout << Sum (A, b) << Endl; return 0 ;}
Exercise 10.15 Writes a lambda, captures the int of the function it is in, and accepts an int parameter, and the lambda should return the and of the captured int and int parameters
#include <iostream>using namespacestd;intSumConst int&a,Const int&B)//function{Auto F= [A] (intb) {returnA + b; };//lambda expression inside the function, a from the int argument where the function is located returnf (b);}intMain () {intA=5, b=6; cout<< sum (A, B) <<Endl; return 0;}
C + + version fifth exercise 10.14 10.15