fork(2) download
  1. #include <functional>
  2. #include <iostream>
  3.  
  4. int foo(double d) { std::cout << d << '\n'; return 0; }
  5.  
  6. char bar(double d) { std::cout << 2*d << '\n'; return '0'; }
  7.  
  8. int main() {
  9. std::function<void(double)> cb;
  10.  
  11. cb = foo; cb(1.0);
  12.  
  13. cb = bar; cb(2.0);
  14.  
  15. return 0;
  16. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
1
4