fork download
  1. struct foo
  2. {};
  3.  
  4. struct bar
  5. {
  6. bar(foo& f)
  7. : f{f}
  8. {}
  9.  
  10. foo& f;
  11. };
  12.  
  13. int main()
  14. {
  15. foo f;
  16. bar b{f};
  17. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In constructor 'bar::bar(foo&)':
prog.cpp:7:14: error: invalid initialization of non-const reference of type 'foo&' from an rvalue of type '<brace-enclosed initializer list>'
stdout
Standard output is empty