fork download
  1. class MyClass {
  2. virtual void function {}
  3. virtual ~MyClass() {}
  4. };
  5. class Derived {
  6. virtual void function {}
  7. virtual ~MyClass() {}
  8. };
  9.  
  10. //is basically
  11.  
  12. struct MyClass_functions {
  13. void function(MyClass this) {}
  14. destructor(MyClass this) {}
  15. }MCFI;
  16. class MyClass {
  17. MyClass_functions* vtable;
  18. MyClass() :vtable(&MCFI) {}
  19. };
  20. struct Derived_functions : public MyClass_functions {
  21. void function(MyClass this) {}
  22. destructor(MyClass this) {}
  23. }DFI;
  24. class Derived {
  25. Derived() :vtable(&DFI) {}
  26. };
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:2:32: error: variable or field ‘function’ declared void
prog.cpp:2:32: error: expected ‘;’ at end of member declaration
prog.cpp:6:32: error: variable or field ‘function’ declared void
prog.cpp:6:32: error: expected ‘;’ at end of member declaration
prog.cpp:7:26: error: declaration of ‘~MyClass’ as member of ‘Derived’
prog.cpp:13:31: error: expected ‘,’ or ‘...’ before ‘this’
prog.cpp:14:28: error: expected ‘,’ or ‘...’ before ‘this’
prog.cpp:14:32: error: ISO C++ forbids declaration of ‘destructor’ with no type [-fpermissive]
prog.cpp: In member function ‘int MyClass_functions::destructor(MyClass)’:
prog.cpp:14:35: warning: no return statement in function returning non-void [-Wreturn-type]
prog.cpp: At global scope:
prog.cpp:16:11: error: redefinition of ‘class MyClass’
prog.cpp:1:11: error: previous definition of ‘class MyClass’
prog.cpp:21:31: error: expected ‘,’ or ‘...’ before ‘this’
prog.cpp:22:28: error: expected ‘,’ or ‘...’ before ‘this’
prog.cpp:22:32: error: ISO C++ forbids declaration of ‘destructor’ with no type [-fpermissive]
prog.cpp: In member function ‘int Derived_functions::destructor(MyClass)’:
prog.cpp:22:35: warning: no return statement in function returning non-void [-Wreturn-type]
prog.cpp: At global scope:
prog.cpp:24:11: error: redefinition of ‘class Derived’
prog.cpp:5:11: error: previous definition of ‘class Derived’
stdout
Standard output is empty