I think you can have to under go through the following code of lines of the program that can help's you to get the knowledge or the information of the replace_if() function in the C++ language :
Code:
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int opincrease (int i)
{
return ++i;
}
int opsum (int i, int j)
{
return i+j;
}
int main ()
{
vector<int> fst;
vector<int> scnd;
vector<int>::iterator t;
for (int i=1; i<6; i++) fst.pushback (i*10);
second.resize(fst.size());
transform (fst.begin(), fst.end(), scnd.begin(), opincrease);
transform (fst.begin(), fst.end(), scnd.begin(), fst.begin(), opsum);
cout << "first contains:";
for (t=fst.begin(); t!=fst.end(); ++t)
cout << " " << *t;
cout << endl;
return 0;
}
Output:
Code:
first contains: 21 41 61 81 101
Bookmarks