Guest User

Untitled

a guest
Jun 24th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. #include <boost/bind.hpp>
  2. #include <boost/function.hpp>
  3. #include <stdio.h>
  4.  
  5. class Base
  6. {
  7. public:
  8. virtual void foo()
  9. {
  10. printf("Base::foo\n");
  11. }
  12. };
  13.  
  14. class Derived : public Base
  15. {
  16. public:
  17. virtual void foo()
  18. {
  19. printf("Derived::foo\n");
  20. }
  21. };
  22.  
  23. int main()
  24. {
  25. Base* pb = new Derived;
  26. boost::function<void()> f = boost::bind(&Base::foo, pb);
  27. f(); // prints "Derived::foo"
  28. }
Add Comment
Please, Sign In to add comment