fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Tuna{
  5.  
  6. int foo(){
  7.  
  8. return 45;
  9. }
  10.  
  11. int(*foobar)() = nullptr;
  12.  
  13.  
  14. Tuna(){
  15.  
  16. foobar = foo;
  17. }
  18. };
  19.  
  20.  
  21. int main() {
  22. Tuna obj;
  23. return 0;
  24. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
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;
       ^
stdout
Standard output is empty