fork download
  1. using namespace std;
  2.  
  3. class A {
  4. public:
  5. double p1, p2;
  6. virtual double fun(p1,p2) = 0;
  7. };
  8.  
  9. class B: public A {
  10. public:
  11. double fun(p1,p2) {
  12. cout << p1+p2;
  13. };
  14. };
  15.  
  16. class C: public A {
  17. public:
  18. double fun(p1,p2) {
  19. cout << p1-p2;
  20. };
  21. };
  22.  
  23. void proc(A** a) {
  24. a[0]->fun();
  25. }
  26.  
  27. int main() {
  28. B b;
  29. C c;
  30. A* a[2];
  31. a[0]=&b;
  32. a[1]=&c;
  33.  
  34. proc(a);
  35. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:6:24: error: ‘p1’ is not a type
prog.cpp:6:27: error: ‘p2’ is not a type
prog.cpp:11:16: error: ‘p1’ is not a type
prog.cpp:11:19: error: ‘p2’ is not a type
prog.cpp: In member function ‘virtual double B::fun(int, int)’:
prog.cpp:12:6: error: ‘cout’ was not declared in this scope
prog.cpp:13:2: warning: no return statement in function returning non-void [-Wreturn-type]
prog.cpp: At global scope:
prog.cpp:18:16: error: ‘p1’ is not a type
prog.cpp:18:19: error: ‘p2’ is not a type
prog.cpp: In member function ‘virtual double C::fun(int, int)’:
prog.cpp:19:3: error: ‘cout’ was not declared in this scope
prog.cpp:20:2: warning: no return statement in function returning non-void [-Wreturn-type]
prog.cpp: In function ‘void proc(A**)’:
prog.cpp:24:12: error: no matching function for call to ‘A::fun()’
prog.cpp:24:12: note: candidate is:
prog.cpp:6:20: note: virtual double A::fun(int, int)
prog.cpp:6:20: note:   candidate expects 2 arguments, 0 provided
stdout
Standard output is empty