Created
October 10, 2010 12:04
-
-
Save chenshuo/619185 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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