- 使用boost function使用类成员函数作为回调函数
#include <iostream> #include <boost/function.hpp>
struct MyTest { int foo(int a){ return a;}; }; int main(int argc, char *argv[]) { boost::function<int (int)> cb; X x; cb = std::bind1st(std::mem_fun(&X::foo), &x); std::cout<<cb(5)<<std::endl; return 0; }