Advertisement
MeehoweCK

Untitled

Mar 16th, 2023
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. // UWAGA: zmienna przekazana do funkcji przez referencję może być modyfikowana wewnątrz tej funkcji
  6. void wypisz(int &liczba)    // przekazanie do funkcji zmiennej poprzez referencję (&)
  7. {
  8.     cout << liczba << endl;     // 2. 10
  9.     ++liczba;
  10.     cout << liczba << endl;     // 3. 11
  11. }
  12.  
  13. int main()
  14. {
  15.     int liczba = 10;
  16.     cout << liczba << endl;     // 1. 10
  17.     wypisz(liczba);
  18.     cout << liczba << endl;     // 4. 11 (po zmodyfikowaniu wartości wewnątrz funkcji)
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement