#include <iostream> using namespace std; class Tuna{ int foo(){ return 45; } int(*foobar)() = nullptr; Tuna(){ foobar = foo; } }; int main() { Tuna obj; return 0; }
Standard input is empty
prog.cpp: In constructor ‘Tuna::Tuna()’: prog.cpp:16:10: error: cannot convert ‘Tuna::foo’ from type ‘int (Tuna::)()’ to type ‘int (*)()’ foobar = foo; ^ prog.cpp: In function ‘int main()’: prog.cpp:14:2: error: ‘Tuna::Tuna()’ is private Tuna(){ ^ prog.cpp:22:7: error: within this context Tuna obj; ^
Standard output is empty