Hi,
I am having hard time trying to pass a function to a STL algorithm, in this case for_each.
Please, what am I doing wrong?
gcc gives me:Code:#include <vector>
#include <algorithm>
using namespace std;
class A
{
vector<int> v;
public:
void incr()
{
for_each(v.begin(), v.end(),
&A.plus );
}
void plus(int& t)
{
t++;
}
};
int main()
{
A a;
a.incr();
return 0;
}
Code:test.cpp: In member function ‘void A::incr()’:
test.cpp:13: error: expected primary-expression before ‘.’ token