fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. int change1(int x){
  6. x = x + 10;
  7. cout << "IN CHANGE 1 "<< x << endl;
  8. return x;
  9. }
  10.  
  11. int change2(int *x){
  12. *x = *x + 10;
  13. cout << "IN CHANGE 2 "<< *x << endl;
  14. return *x;
  15. }
  16.  
  17. int main(){
  18. int a = 5;
  19. int *onoma;
  20. cout << a << " " << &a << endl;
  21.  
  22. onoma = new(int);
  23. *onoma = 10;
  24. cout << onoma << " " << *onoma << endl;
  25.  
  26.  
  27. //a = onoma;
  28. //cout << a << " " &a << endl;
  29. int k;
  30. cout << "BEFORE CHANGE 1 " << a << endl;
  31. k = change1(a);
  32. cout << "OUT OF CHANGE 1 " << a << endl;
  33.  
  34.  
  35. cout << "BEFORE CHANGE 2 " << *onoma << endl;
  36. k = change2(onoma);
  37. cout << "OUT OF CHANGE 2 " << *onoma << endl;
  38.  
  39.  
  40. return 0;
  41. }
Success #stdin #stdout 0s 4884KB
stdin
Standard input is empty
stdout
5 0x7ffd1d314da4
0x565433a39e80 10
BEFORE CHANGE 1  5
IN CHANGE 1 15
OUT OF CHANGE 1  5
BEFORE CHANGE 2  10
IN CHANGE 2 20
OUT OF CHANGE 2  20