Example & Tutorial understanding programming in easy ways.

Define lambda expression in C++

Lambda Function:
Basically, in C++ lambda expression are used to write the inline function.
-Return type of lanbda expression are evaluted by compiler itself.

Syntax-
capture_clause(parameters)->return-type
{
definition of method
}

program:

#include < bits/stdc++.h>
using namespace std;
//Display vector function
void printVector(vector< int> v)
{
// lambda expression to print vector
for_each(v.begin(), v.end(), [](int i)
{
std::cout << i << " ";
});
cout << endl;
}
int main()
{
vector v {4, 1, 3, 5, 2, 3, 1, 7};
printVector(v);
}


output-

4 1 3 5 2 3 1 7




Read More →
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!