fork(5) download
  1. struct Base { };
  2.  
  3. struct Derived : public Base { };
  4.  
  5.  
  6. int main() {
  7. Base & obj = Derived();
  8. }
  9.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:7:30: error: invalid initialization of non-const reference of type ‘Base&’ from an rvalue of type ‘Derived’
         Base & obj = Derived();
                              ^
prog.cpp:7:16: warning: unused variable ‘obj’ [-Wunused-variable]
         Base & obj = Derived();
                ^
stdout
Standard output is empty