fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int& f( int& v )
  5. {
  6. cout << "f()" << v << endl;
  7. v *= 2;
  8. return v;
  9. }
  10.  
  11. int main() {
  12.  
  13. int i = 10;
  14. //f(i) = f(i) + 42;
  15. int ii = 20;
  16. f(ii) = f(i) + 42;
  17. cout << "i=" << i << endl;
  18.  
  19. int j = 10;
  20. f(j) += 42;
  21. cout << "j=" << j << endl;
  22.  
  23. // system( "pause" );
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0s 2896KB
stdin
Standard input is empty
stdout
f()20
f()10
i=20
f()10
j=62