Having a function inside for_each statement
Dec 4, 2014 at 1:03pm UTC
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.
Dec 4, 2014 at 1:03pm UTC
both of them are in same class.
Dec 4, 2014 at 2:09pm UTC
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.