fork download
  1. #include <iostream>
  2. #include <functional>
  3.  
  4. typedef int (*FPtr)(int);
  5.  
  6. int add(std::function<int (int)> f, int x, int y) {
  7. return f(x) + f(y);
  8. }
  9.  
  10. int func3(int a, int x) {
  11. return a*x;
  12. }
  13.  
  14. int main()
  15. {
  16. std::cout << add(std::bind(func3, std::placeholders::_1, 4), 2, 3) << std::endl;
  17. }
  18.  
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
20