Skip to content

Instantly share code, notes, and snippets.

@chenshuo
Created October 10, 2010 12:04
Show Gist options
  • Save chenshuo/619185 to your computer and use it in GitHub Desktop.
Save chenshuo/619185 to your computer and use it in GitHub Desktop.
#include <boost/bind.hpp>
#include <boost/function.hpp>
#include <stdio.h>
class Base
{
public:
virtual void foo()
{
printf("Base::foo\n");
}
};
class Derived : public Base
{
public:
virtual void foo()
{
printf("Derived::foo\n");
}
};
int main()
{
Base* pb = new Derived;
boost::function<void()> f = boost::bind(&Base::foo, pb);
f(); // prints "Derived::foo"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment