Advertisement
MeehoweCK

Untitled

May 6th, 2021
684
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void funkcja(int& liczba)       // przekazanie zmiennej przez referencję (pracujemy na oryginalnej zmiennej)
  6. {
  7.     cout << &liczba << endl;    // TA SAMA KOMÓRKA PAMIĘCI
  8.     cout << liczba << endl;     // 1.   10
  9.     ++liczba;
  10.     cout << liczba << endl;     // 2.   11
  11.     liczba *= 10;
  12.     cout << liczba << endl;     // 3.   110
  13.     --liczba;
  14.     cout << liczba << endl;     // 4.   109
  15. }
  16.  
  17. int main()
  18. {
  19.     int liczba = 10;
  20.  
  21.     cout << &liczba << endl;    // TA SAMA KOMÓRKA PAMIĘCI
  22.  
  23.     funkcja(liczba);
  24.  
  25.     cout << liczba << endl;     // 5.   109
  26.  
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement