fork(9) download
  1. #include <iostream>
  2.  
  3. int add1(int n) { return n+1; }
  4. int add2(int n) { return n+2; }
  5.  
  6. template<typename Adder>
  7. void AddHandler(int n, Adder adder)
  8. {
  9. int r = adder(n);
  10. std::cout << r << std::endl;
  11. }
  12.  
  13. int main(void)
  14. {
  15. AddHandler(1, add1);
  16. AddHandler(3, add2);
  17.  
  18. return 0;
  19. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
2
5