Here’s my class definition:
class A {
public:
void do_lengthy_work() {
cout << "working." << endl;
}
};
I have an object of type A, and I want to call do_lengthy_work() on it:
A a;
a.do_lengthy_work();
Is it also possible to call the same method using some variant of the following?
A::do_lengthy_work(a);
You can wrap the function with
mem_fun_ref:This can be very useful for STL algorithms like
for_each:If you have an
A *, you would usemem_fun: