When using the std::for_each,
class A; vector<A*> VectorOfAPointers; std::for_each(VectorOfAPointers.begin(), VectorOfAPointers.end(), std::mem_fun(&A::foo));
If we have classes inheriting from A and implementing foo(), and we hold a vector of pointers to A, is there any way to call a polymorphic call on foo(), rather then explicitly calling A::foo()? Note: I can’t use boost, only standard STL.
Thanks, Gal
It actually works this way.
prints
So it does exactly what you want. Check that
virtualkeywords are present though, it’s easy to forget them.