Having a function inside for_each statement

Dear all,

I keep on getting error message while trying to pass a function inside a for_each loop.. I have a vector and i used for_each loop to go through the rows in that vector, Now I need a function to do something

Example this is what I am trying to achieve

for_each (label.begin(), label.end(), addToTemporaryVector());

1
2
3
4
5
void DataPartitioning::addToTemporaryVector(){

    cout<<"sucess";

}


but I get an error message saying: error: invalid use of void expression

Thanks for looking at it.
both of them are in same class.
for_each requires a certain signature of the function. The only parameter needs to be the value type of your vector.

I.e. if label takes string the parameter to addToTemporaryVector is string
Topic archived. No new replies allowed.