#include <iostream> void f(); int main() { void (*fp1)() = &f; //valid void (*fp2)() = f; //valid void (&fr1)() = f; //valid void (&fr2)() = &f; //not valid }
Standard input is empty
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 ^
Standard output is empty