// 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