15 Jul
2002
15 Jul
'02
9:55 a.m.
From: "Phil Nash"
#include "stdafx.h" #include
#include class MyClass { public: int MyMember(int,int,int); };
int MyClass::MyMember(int x,int y,int z) { int a = x + y + z; }
int main(int argc, char* argv[]) { MyClass mcl; boost::function3
bf; bf = boost::bind(&MyClass::MyMember,&mcl); bf(2,3,4); return 0; } Yep, there it is... you need to tell bind the ordinal positions of each argument to bind to. Just rewrite the line that constructs bind something like this:
bf = boost::bind(&MyClass::MyMember,&mcl, _1, _2, _3);
...and it should work.
Yes. bind() requires that you supply exactly the number of arguments that is required by the function (object.) http://www.boost.org/libs/bind/bind.html#err_num_args