fork download
  1. #include <iostream>
  2. #include <functional>
  3. using namespace std;
  4.  
  5.  
  6. int addTheNumbers(int a, int b){
  7. return a + b;
  8. }
  9. void sayHello(){
  10. cout << "hello there, I was accesed through another function\n";
  11. }
  12. void printTheNumbers(int a, int b, std::function<void()> function){
  13.  
  14. function();
  15.  
  16. }
  17.  
  18.  
  19.  
  20.  
  21. int main(int argc, const char * argv[]) {
  22.  
  23.  
  24. printTheNumbers(2, 3, sayHello);
  25.  
  26. return 0;
  27.  
  28. }
Success #stdin #stdout 0s 3140KB
stdin
Standard input is empty
stdout
hello there, I was accesed through another function