fork download
  1. #include <random>
  2. #include <iostream>
  3.  
  4. struct Base
  5. {
  6. virtual void f()=0;
  7. };
  8.  
  9. struct Derived: Base
  10. {
  11. // void f() override; // NEED DECLARATION
  12. };
  13.  
  14. void Derived::f(){}
  15.  
  16. int main()
  17. {
  18. Derived d;
  19. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:14:17: error: no 'void Derived::f()' member function declared in class 'Derived'
 void Derived::f(){}
                 ^
prog.cpp: In function 'int main()':
prog.cpp:18:13: error: cannot declare variable 'd' to be of abstract type 'Derived'
     Derived d;
             ^
prog.cpp:9:8: note:   because the following virtual functions are pure within 'Derived':
 struct Derived: Base
        ^
prog.cpp:6:18: note: 	virtual void Base::f()
     virtual void f()=0;
                  ^
stdout
Standard output is empty