fork download
  1. #include <iostream>
  2.  
  3. typedef int (*TMyFunctionPointer)(int, int);
  4.  
  5. int Add(int a, int b)
  6. {
  7. return a + b;
  8. }
  9.  
  10. int SomeFunctionThatTakesAFunctionPointer(int (*myFunctionPointer)(int a, int b))
  11. {
  12. return myFunctionPointer(1, 2);
  13. }
  14.  
  15. int TypeDefVersion(TMyFunctionPointer myFunctionPointer)
  16. {
  17. return myFunctionPointer(1, 2);
  18. }
  19.  
  20. int main(int argc, const char* argv[])
  21. {
  22. std::cout << SomeFunctionThatTakesAFunctionPointer(Add) << std::endl;
  23. std::cout << TypeDefVersion(Add) << std::endl;
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
3
3