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

Standard output is empty