example for bind

来源:互联网 发布:刺客信条2mac中文版 编辑:程序博客网 时间:2024/05/18 22:50
#include <iostream>#include <boost/bind.hpp>#include <boost/function.hpp>using namespace std;class People{public:People(const string& name):_name(name){}void SaySomething(const string& msg) const{cout<<_name<<" said: "<< msg << endl;}private:string _name;};void RunSomethingforName(const string& name, boost::function<void(const People&)> f){People p(name);f(p);}int main(int argc, char* argv[]){RunSomethingforName("Mike", boost::bind(&People::SaySomething, _1,"fuck"));return 0;}

0 0
原创粉丝点击