Boost logo

Boost Users :

From: Meryl Silverburgh (silverburgh.meryl_at_[hidden])
Date: 2006-02-15 17:08:18


Thanks how can I call a function with 2 more parameters, like this:
How can I pass 'param1', 'param2' to the fuction doStuff?

void A::aFunction( float param1, float param2) {

vector<int> aVector;
aVector.push_back(1);
aVector.push_back(2);
aVector.push_back(3);
aVector.push_back(4);

// want to loop thru the list and call A::print(int i, float param1,
float param2)?
}

void A::doStuff(int i, float param1, float param2) {

}

On 2/14/06, Noel Yap <noel.yap_at_[hidden]> wrote:
> boost::bind isn't necessary for this.
>
> std::copy(
> aVector.begin(),
> aVector.end(),
> std::ostream_iterator< std::string >(std::cout, "\n"));
>
> If you really want to use boost::bind, it would be something like:
>
> std::for_each(
> aVector.begin(),
> aVector.end(),
> boost::bind(
> &A::print,
> _1 ) );
>
> although I haven't tried it out myself.
>
> On 2/14/06, Meryl Silverburgh <silverburgh.meryl_at_[hidden]> wrote:
> > I have a int vector, and I would like to loop thru the vector and call
> > a function which takes an int (in this case, I want to print).
> >
> > t
> > void A::aFunction() {
> >
> > vector<int> aVector;
> > aVector.push_back(1);
> > aVector.push_back(2);
> > aVector.push_back(3);
> > aVector.push_back(4);
> >
> > // want to loop thru the list and call A::print(int i)?
> > }
> >
> >
> > void A::print(int i) {
> >
> > }
> >
> > how can I do that using boost bind library?
> >
> > _______________________________________________
> > Boost-users mailing list
> > Boost-users_at_[hidden]
> > http://lists.boost.org/mailman/listinfo.cgi/boost-users
> >
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net