B
Belebele
Suppose I want to use some object's member function as the action
passed to a for_each call:
class A {
...
public:
void foo(int );
};
A a;
int ints[5];
....
for_each(0, 5, /*i want to call a.foo for each element in the range*/);
What is a good elegant way to do that?
What I did was to wrap the a object into a unary_function-derived
object and then pass the unary_function to the for_each method.
Any other ideas?
Thanks
passed to a for_each call:
class A {
...
public:
void foo(int );
};
A a;
int ints[5];
....
for_each(0, 5, /*i want to call a.foo for each element in the range*/);
What is a good elegant way to do that?
What I did was to wrap the a object into a unary_function-derived
object and then pass the unary_function to the for_each method.
Any other ideas?
Thanks