fork(3) download
  1. #include <iostream>
  2. #include <functional>
  3.  
  4. class Manager
  5. {
  6. public:
  7. Manager() :x_(0) {}
  8. const int GetX() const { return x_; }
  9. inline void SetX(int x) { x_ = x; }
  10. private:
  11. int x_;
  12. };
  13.  
  14. void Print(int x) { std::cout << x << std::endl; }
  15.  
  16. int main()
  17. {
  18. Manager m;
  19. auto test1 = std::bind(Print, m.GetX()+5);
  20. auto test2 = std::bind(Print, std::bind(std::plus<>(),m.GetX(), 10));
  21. test1();
  22. test2();
  23. m.SetX(5566);
  24. test1();
  25. test2();
  26.  
  27. return 0;
  28. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
5
10
5
10