Defining the Lambda Expression Solution - C++ STL

C++ examples for STL:Lambda

Description

Defining the Lambda Expression Solution

Demo Code

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

void ProcessVector(vector<int>& vect)
{
    for_each(vect.begin(), vect.end(), [](int x){cout << x << endl;});
}

int main()/*from   w ww  .ja va 2s  .co  m*/
{
    vector<int> myV;
    myV.push_back(1);
    myV.push_back(2);
    myV.push_back(3);
    myV.push_back(4);

    ProcessVector(myV);
}

Result


Related Tutorials