fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int add(int a, int b) {
  5. return a + b;
  6. }
  7.  
  8. int mul(int a, int b) {
  9. return a * b;
  10. }
  11.  
  12. int main() {
  13.  
  14. int x = 10, y = 20;
  15. int (*f)(int, int);
  16. f = add;
  17. cout << f(x, y) << endl;
  18. f = mul;
  19. cout << f(x, y) << endl;
  20.  
  21. cout << "&add = " << (void *) add << endl;
  22. cout << "&mul = " << (void *) mul << endl;
  23.  
  24. return 0;
  25. }
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout
30
200
&add = 0x562baf2ba270
&mul = 0x562baf2ba280