fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct A
  5. {
  6. int x;
  7. A();
  8. ~A();
  9. A(int);
  10. };
  11. A::~A() {}
  12. A::A() : x(0) {}
  13. A::A(int _x) : x(_x) {}
  14.  
  15. void func(A &a)
  16. {
  17. a.x=10;
  18.  
  19. }
  20.  
  21. int main()
  22. {
  23. A a;
  24.  
  25. func(a);
  26. func(A());
  27.  
  28. return 0;
  29. }
Compilation error #stdin compilation error #stdout 0s 3452KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:26:13: error: invalid initialization of non-const reference of type 'A&' from an rvalue of type 'A'
     func(A());
             ^
prog.cpp:15:6: note:   initializing argument 1 of 'void func(A&)'
 void func(A &a)
      ^
stdout
Standard output is empty