fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void (*func)();
  5.  
  6. void foo(){
  7. cout << "foo" << endl;
  8. }
  9. void bar(){
  10. cout << "bar" << endl;
  11.  
  12. }
  13.  
  14. int main() {
  15. func = foo;
  16. func();
  17. func = bar;
  18. func();
  19.  
  20.  
  21. return 0;
  22. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
foo
bar