class MyClass {
public:
int DoSomething(){
}
};
now say you have
std::vector
you can use something like this
for_each(classes.begin(), classes.end(), &DoSomething);
where DoSomething is
int DoSomething(MyClass& e){
d.DoSomething();
}
to call the member function DoSomething rather than the wrapper function use function calls like these
for_each(classes.begin(), classes.end(), mem_fun_ref(&MyClass::DoSomething));
if the classes vector was defined something like this
vector
then you would use something like this
for_each(classes.begin(), classes.end(), mem_fun(&MyClass::DoSomething));
No comments:
Post a Comment