fork(2) download
  1. #include <iostream>
  2. #include <string>
  3. #include <tr1/functional>
  4.  
  5. struct A {
  6. A(const std::string& n) : name_(n) {}
  7. void printit(const std::string& s)
  8. {
  9. std::cout << name_ << " says " << s << std::endl;
  10. }
  11. private:
  12. const std::string name_;
  13. };
  14.  
  15. int main()
  16. {
  17. A a("Joe");
  18. std::tr1::function<void(const std::string&)> f = std::tr1::bind(&A::printit, &a, std::tr1::placeholders::_1);
  19. f("Hi");
  20. }
  21.  
Success #stdin #stdout 0.01s 2860KB
stdin
Standard input is empty
stdout
Joe says Hi