fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class AbsBase
  6. {
  7. virtual void init() = 0;
  8. virtual void work() = 0;
  9. };
  10.  
  11. class AbsInit : public virtual AbsBase
  12. {
  13. public:
  14. int n;
  15. AbsInit(int x)
  16. {
  17. n = x;
  18. }
  19. void init() { }
  20. };
  21.  
  22. class AbsWork : public virtual AbsBase
  23. {
  24. void work() { }
  25. };
  26.  
  27. class NotAbsTotal : public AbsInit, public AbsWork
  28. {
  29. public:
  30. int n;
  31. NotAbsTotal(int x){
  32. n = x;
  33. }
  34.  
  35. }; // Nothing, both should be defined
  36.  
  37.  
  38. int main() {
  39. NotAbsTotal foo();
  40. cout << foo.n << endl;
  41.  
  42. }
  43.  
Compilation error #stdin compilation error #stdout 0s 3452KB
stdin
Standard input is empty
compilation info
prog.cpp: In constructor 'NotAbsTotal::NotAbsTotal(int)':
prog.cpp:31:23: error: no matching function for call to 'AbsInit::AbsInit()'
     NotAbsTotal(int x){
                       ^
prog.cpp:15:5: note: candidate: AbsInit::AbsInit(int)
     AbsInit(int x)
     ^
prog.cpp:15:5: note:   candidate expects 1 argument, 0 provided
prog.cpp:11:7: note: candidate: AbsInit::AbsInit(const AbsInit&)
 class AbsInit : public virtual AbsBase
       ^
prog.cpp:11:7: note:   candidate expects 1 argument, 0 provided
prog.cpp:11:7: note: candidate: AbsInit::AbsInit(AbsInit&&)
prog.cpp:11:7: note:   candidate expects 1 argument, 0 provided
prog.cpp: In function 'int main()':
prog.cpp:40:15: error: request for member 'n' in 'foo', which is of non-class type 'NotAbsTotal()'
   cout << foo.n << endl;
               ^
stdout
Standard output is empty