fork(7) download
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <algorithm>
  5. #include <functional>
  6. #include <utility>
  7.  
  8. class Foo {
  9. public:
  10. int i;
  11. void test() {
  12. std::cout << i << std::endl;
  13. }
  14. };
  15.  
  16.  
  17. int main()
  18. {
  19. Foo f;
  20. f.i = 100;
  21. auto func = std::bind(&Foo::test, std::ref(f));
  22. f.i = 1000;
  23. func();
  24.  
  25. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
1000