Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- // UWAGA: zmienna przekazana do funkcji przez referencję może być modyfikowana wewnątrz tej funkcji
- void wypisz(int &liczba) // przekazanie do funkcji zmiennej poprzez referencję (&)
- {
- cout << liczba << endl; // 2. 10
- ++liczba;
- cout << liczba << endl; // 3. 11
- }
- int main()
- {
- int liczba = 10;
- cout << liczba << endl; // 1. 10
- wypisz(liczba);
- cout << liczba << endl; // 4. 11 (po zmodyfikowaniu wartości wewnątrz funkcji)
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement