> sum = for_each(vec.begin(), vec.end(), sum.operator()(int) ); ...(3)
> (3) fails, does it means the third argument of "for_each" couldn't be a
> function pointer? What will the code be if I want to pass a function
> pointer here? Thanks for help!
sum.operator()(int) isn't valid. You can't take an address of a member
function from an instance, you have to take it from the class. As such
its signature changes from what it was, (int) in this case, to
accepting a pointer to an instance of that class...so (Sum*, int) in
this case. To use such in an algorithm you need a binder. I use TR1
bind, which can be found as boost::bind.
sum = for_each(vec.begin(), vec.end(), boost::bind(&Sum:

perator(),
&sum, _1));