fork download
  1. #include <iostream>
  2.  
  3. void f();
  4.  
  5. int main()
  6. {
  7. void (*fp1)() = &f; //valid
  8. void (*fp2)() = f; //valid
  9. void (&fr1)() = f; //valid
  10. void (&fr2)() = &f; //not valid
  11. }
  12.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:10:19: error: invalid initialization of non-const reference of type 'void (&)()' from an rvalue of type 'void (*)()'
  void (&fr2)() = &f; //not valid
                   ^
stdout
Standard output is empty