Wow, all these informative replies, and I only fully understand about 25% of them

JD: I agree - sometimes it's easier to use your own for() loop rather than struggling to work out the exact syntax for what you want to do. But, once you work it out, you can save yourself some time forever, which is why I posted this

I'm using MSVC6.0 SP3 (acronyms R us) with the standard dinkumware STL. Can't use STLport because it requires all that library compilation up-front.
Stoffel: I think I see what you mean now. I was expecting mem_fun to return a function object that would be given a single parameter, but in fact it returns a function object that is parameterised by the object it gets called upon. Which makes sense. The fact that the member function required another parameter just made it more complicated, and required the binder object. I think. Anyway, you said "mem_fun calls a member function of Creature*", whereas it looks to me like, in my example, mem_fun was expecting an App* from for_each, and it was actually getting Creature*, hence the error. Is this right?
Void: I'm sure the definition you gave is right, it just made no sense

All those meaningless variable names for hypothetical parameters does my head in. I can only handle worked examples

MKH:
"AFAICT, You have to create a new functor for each & every method you want to use with for_each." What's the problem with this? After all, as was shown in the assembly listing below, when such an object contains no members (99% of the time) it gets optimised away to nothing. And when it does have members, that's some sort of state that you would have had to preserve anyway. Maybe there's something I'm missing though, not really being an STL expert.
Thanks everybody for the detailed discussion.
Edited by - Kylotan on July 15, 2001 11:40:16 AM