fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct Interf {
  5. virtual void foo(const int& a) = 0;
  6. };
  7. struct Impl : Interf {
  8. virtual void foo(int& a) override {}
  9. };
  10.  
  11.  
  12. int main() {
  13. Impl i;
  14. int b;
  15. i.foo(b);
  16. // your code goes here
  17. return 0;
  18. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:8:15: error: 'virtual void Impl::foo(int&)' marked 'override', but does not override
  virtual void foo(int& a) override {}
               ^
prog.cpp: In function 'int main()':
prog.cpp:13:7: error: cannot declare variable 'i' to be of abstract type 'Impl'
  Impl i;
       ^
prog.cpp:7:8: note:   because the following virtual functions are pure within 'Impl':
 struct Impl : Interf {
        ^
prog.cpp:5:18: note: 	virtual void Interf::foo(const int&)
     virtual void foo(const int& a) = 0;
                  ^
stdout
Standard output is empty