I wrote the following class:
class A {
//.. class description
};
class B {
void foo(A* a) {
//.. function description
}
void bar() {
for_each ( H->begin(), H->end(), &B::foo );
}
// member variable
vector<A*> *H; // initialize in elsewhere
}
In this case, the error message was
must use '.*' or '->*' to call pointer-to-member function in '__f (...)'How can I call member function 'foo' in for_each command?
I aware that if function foo is the member function of class A, mem_fun should be used in for_each argument.
However, in my case, foo is the member function of class B. Is 'mem_fun' should used in this case?
In case of use mem_fun(&B::foo) instead of &B::foo, I got an error message;
argument of type 'void (H::)(A*) does not match 'void (H::*)(A*)'
I appreciate for your comment.