fork(1) download
  1. #include <functional>
  2. #include <iostream>
  3.  
  4. struct Foo {
  5. Foo(int num) : num_(num) {}
  6. void print_add(int i) const { std::cout << num_+i << '\n'; }
  7. int num_;
  8. };
  9.  
  10. int main()
  11. {
  12. std::function<void(const Foo&, int)> f_add_display = &Foo::print_add;
  13. const Foo foo(5);
  14. f_add_display(foo, 1);
  15. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
6