fork download
  1. class Base
  2. {
  3. Base(int i) {}; //Has a constructor therefore does not get a free noargs constructor
  4. };
  5.  
  6. class Derived : public Base
  7. {
  8. };
  9.  
  10. int main()
  11. {
  12. /*Not actually possible because Derived will get a free noargs constructor
  13.   which will attempt to invoke the non existant no args constructor of Base.
  14.   */
  15. Derived d;
  16.  
  17. return 0;
  18. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In constructor ‘Derived::Derived()’:
prog.cpp:6:11: error: no matching function for call to ‘Base::Base()’
prog.cpp:6:11: note: candidates are:
prog.cpp:3:9: note: Base::Base(int)
prog.cpp:3:9: note:   candidate expects 1 argument, 0 provided
prog.cpp:1:11: note: Base::Base(const Base&)
prog.cpp:1:11: note:   candidate expects 1 argument, 0 provided
prog.cpp: In function ‘int main()’:
prog.cpp:15:18: note: synthesized method ‘Derived::Derived()’ first required here 
stdout
Standard output is empty