fork download
  1. #include <iostream>
  2.  
  3. void _init_without(int& a, int& b) { a = 3; b = 4; }
  4.  
  5. void _init(int& a, int& b) { a = 2; b = 3; }
  6.  
  7. void init(int& a, int& b, void (*f)(int&, int&)){
  8. f(a, b); // function pointer
  9. _init_without(a, b) // without
  10. }
  11.  
  12. int main(){
  13. int x, b;
  14. init(x, b, _init);
  15. std::cout<<x << " " << b;
  16. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘void init(int&, int&, void (*)(int&, int&))’:
prog.cpp:10:1: error: expected ‘;’ before ‘}’ token
 }
 ^
stdout
Standard output is empty