fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. // 'const' means *you* can't change the value
  5. // It does not mean the value cannot change
  6.  
  7. void f(const int& x, int* y)
  8. {
  9. cout << "x = " << x << endl;
  10. *y = 5;
  11. cout << "x = " << x << endl;
  12. }
  13.  
  14. int main()
  15. {
  16. int x = 10;
  17. f(x, &x);
  18. }
  19.  
Success #stdin #stdout 0.01s 2680KB
stdin
Standard input is empty
stdout
x = 10
x = 5