fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int foo()
  5. {
  6. cout<<"function foo is called";
  7. return 2;
  8. }
  9.  
  10. int goo()
  11. {
  12. cout<<"function goo is called";
  13. return 3;
  14. }
  15.  
  16. int main()
  17. {
  18. int (*pFoo)()=&foo; // pFoo points to function foo()
  19. cout<<pFoo()<<endl;
  20. pFoo = &goo; // pFoo now points to function goo()
  21. cout<<pFoo;
  22.  
  23. return 0;
  24. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
function foo is called2
1