Hi all,
I pass to the transform algorithm two vectors, and the suma function.
#include <algorithm>
#include <iostream>
#include <iterator>
#include <vector>
using namespace std;
class Duo{
public:
int one;
int two;
};
Duo suma(Duo first, Duo last){
Duo ret;
ret.one=first.one+last.one;
ret.two=first.two+last.two;
return ret;
}
int main(){
vector<Duo> vec1;
vector<Duo> vec2;
Duo obj;
for (int i=0; i<5; i++){
obj.one=i;
obj.two=i;
vec1.push_back(obj);
}
transform(vec1.begin(),vec1.end(),vec2.begin(),suma);
return 0;
}
When I compile it, I get the following error.
/usr/include/c++/4.5/bits/stl_algo.h||In function �_OIter std::transform(_IIter, _IIter, _OIter, _UnaryOperation)
[with _IIter = __gnu_cxx::__normal_iterator<Duo*, std::vector<Duo> >, _OIter =
__gnu_cxx::__normal_iterator<Duo*, std::vector<Duo> >, _UnaryOperation = Duo (*)(Duo, Duo)]':|
/home/rav/Desktop/bas/main.cpp:30|54|instantiated from here|
/usr/include/c++/4.5/bits/stl_algo.h|4688|error: too few arguments to function|
||=== Build finished: 1 errors, 0 warnings ===|
What am I'm doing wrong? How can I fix it?
thanks!!
santiagorf