fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void byref(int &x) {
  6. x++;
  7. }
  8.  
  9. void byptr(int *x) {
  10. if (x != NULL) (*x)++;
  11. }
  12.  
  13. int main() {
  14.  
  15. int x= 0;
  16.  
  17. cout << x << endl;
  18. byref(x);
  19. cout << x << endl;
  20. byptr(&x);
  21. cout << x << endl;
  22.  
  23. return 0;
  24. }
Success #stdin #stdout 0s 2852KB
stdin
stdout
0
1
2