fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void f(int &p)
  5. {
  6. int &p2 = p + 1;
  7. cout << "Value is: " << p2;
  8. }
  9.  
  10.  
  11.  
  12. int main() {
  13. // your code goes here
  14. int i = 10;
  15.  
  16. f(i);
  17. return 0;
  18. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'void f(int&)':
prog.cpp:6:15: error: invalid initialization of non-const reference of type 'int&' from an rvalue of type 'int'
   int &p2 = p + 1;
               ^
stdout
Standard output is empty