I’m getting an error: invalid use of void expression error within my draw_all_seq_inside2 method!
template <typename Container>
void draw_all_seq_inside(Container &c, const rectangle &w){
typename Container::iterator iter;
for(iter = c.begin() ; iter != c.end() ; iter++){
(*iter)->inside_window(w._btm_left, w._top_right);
}
}
template <typename Container>
void draw_all_seq_inside2(Container &c, const rectangle &w){
for_each(c.begin(),c.end(),draw_all_seq_inside(c, w));
}
I’m calling the draw_all_seq_inside within the for_each algorthim, am I doing this the correct way?
The third argument should be a callable-entity. That is, it could be a function object, or function pointer which can accepts one argument of type of the element of container
c.But in your code, you’re calling the function and passing the returned value (which is
void) as third argument tostd::for_each. That is the cause of the error.