fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here\
  6. int x = 10;
  7. int &ref = x;
  8.  
  9. ++ref;
  10.  
  11. cout<<x<<"\t"<<ref<<endl;
  12.  
  13. int y = 20;
  14. ref = y;
  15.  
  16. ++ref;
  17.  
  18. cout<<y<<"\t"<<ref<<endl;
  19.  
  20. int z = 30;
  21. int &ref = z;
  22.  
  23. ++ref;
  24.  
  25. cout<<z<<"\t"<<ref<<endl;
  26.  
  27. cout<<x<<"\t"<<y<<"\t"<<z<<endl;
  28. return 0;
  29. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:7:13: error: 'x' was not declared in this scope
  int &ref = x;
             ^
prog.cpp:21:7: error: redeclaration of 'int& ref'
  int &ref = z;
       ^
prog.cpp:7:7: note: 'int& ref' previously declared here
  int &ref = x;
       ^
stdout
Standard output is empty