fork download
  1. #include <stdio.h>
  2.  
  3. class Method {
  4. public:
  5. virtual void Rum();
  6. };
  7. class Euler : public Method {
  8. virtual void Rum() {
  9. printf("ahoj\n");
  10. }
  11. };
  12. class Kutta : public Method {
  13. virtual void Rum() {
  14. printf("ahoj2\n");
  15. }
  16. };
  17. class Simulator {
  18. public:
  19. Method *pointer;
  20. Simulator();
  21. void setmethod(Method* m) { pointer = m; }
  22. };
  23.  
  24. int main() {
  25. Simulator s ;
  26. s.setmethod(new Kutta());
  27. s.pointer->Rum();
  28. s.setmethod(new Euler());
  29. s.pointer->Rum();
  30. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/home/wWTHI5/cclXxbEJ.o: In function `main':
prog.cpp:(.text+0x16): undefined reference to `Simulator::Simulator()'
/home/wWTHI5/cclXxbEJ.o:(.rodata._ZTI5Kutta[typeinfo for Kutta]+0x8): undefined reference to `typeinfo for Method'
/home/wWTHI5/cclXxbEJ.o:(.rodata._ZTI5Euler[typeinfo for Euler]+0x8): undefined reference to `typeinfo for Method'
collect2: ld returned 1 exit status
stdout

Standard output is empty