C
Chris Roth
I have a vector (v) containing objects of class C.
class C
{
private:
double d;
public:
void foo( B& b );
};
class B
{
public:
int i;
double x;
// lots of other things, which is why its passed by reference.
};
I'd like to run function foo for each element in v. foo takes one
argument of class B passed by reference. The following lines produces a
reference to reference error:
vector<C> v(50);
B b;
for_each( v.begin(), v.end(),
bind2nd( mem_fun_ref(&C::foo), b ) );
How can I get around this using for_each?
class C
{
private:
double d;
public:
void foo( B& b );
};
class B
{
public:
int i;
double x;
// lots of other things, which is why its passed by reference.
};
I'd like to run function foo for each element in v. foo takes one
argument of class B passed by reference. The following lines produces a
reference to reference error:
vector<C> v(50);
B b;
for_each( v.begin(), v.end(),
bind2nd( mem_fun_ref(&C::foo), b ) );
How can I get around this using for_each?