Boost Bind 类成员函数指针
2010-08-21 15:38
501 查看
// Test_BOOST_BIND_FUNCTION.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <boost/mem_fn.hpp> #include <boost/ref.hpp> #include <boost/type.hpp> #include <boost/bind.hpp> #include <boost/function.hpp> #include <iostream> class button { public: boost::function<void()> onClick; }; class player { public: void play(){std::cout<<"Play!/n";} void stop(){std::cout<<"Stop!/n";} }; button playButton, stopButton; player thePlayer; void connect() { playButton.onClick = boost::bind(&player::play, &thePlayer); stopButton.onClick = boost::bind(&player::stop, &thePlayer); } int _tmain(int argc, _TCHAR* argv[]) { connect(); playButton.onClick(); stopButton.onClick(); return 0; }
Reference:
http://www.boost.org/doc/libs/1_44_0/libs/bind/bind.html
http://msdn.microsoft.com/en-us/library/bb982702(v=VS.90).aspx
相关文章推荐
- 简析function/bind如何实现类成员函数指针绑定调用
- boost::bind绑定成员变量,函数书嵌套
- boost::bind绑定成员函数时,第一个参数传递对象的特殊情况
- boost::bind boost::function绑定万能函数测试2(类成员函数和虚函数)
- C++ 类的成员函数指针 ( function/bind )
- boost::function 通过boost::bind调用类成员函数
- boost::function 通过boost::bind调用类成员函数
- 仿函数 <- 函数指针 成员函数 std::bind
- boost::bind 函数与类成员的区别
- C++ boost::bind 函数参数对数组、指针的支持不够好?欢迎指教
- boost::bind无参非成员函数的绑定和调用(一)
- C++11 FAQ中文版:std::function 和 std::bind(在cocos2dx中:bind能够把类内函数转成类外函数(通过传入这个类的指针 this 得到被捆绑的成员函))
- boost::function 通过boost::bind调用类成员函数
- 使用tr1::function和tr1::bind实现类的非静态成员函数指针
- boost::bind 绑定成员函数
- Boost.Bind用法详解(一) 2008-05-09 15:50:50| 分类: C++ |字号 订阅 Boost.Bind 为函数和函数对象提供了一致的语法,对于值语义和指针语义也一样。
- 使用boost.bind绑定class的成员函数作为boost thread的入口
- 一般函数指针和成员函数指针的区别与联系
- 指向类成员函数的指针
- std::function与std::bind 函数指针