mirror of
https://github.com/szymon-jozef/ZUT-notatki.git
synced 2026-10-28 11:10:38 +01:00
notatki
This commit is contained in:
15
uczelnia/2_semestr/programowanie/laby/lab2/zad5.cpp
Normal file
15
uczelnia/2_semestr/programowanie/laby/lab2/zad5.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
void podwoj1(int x) { x *= 2; }
|
||||
void podwoj2(int &x) { x *= 2; }
|
||||
|
||||
int main() {
|
||||
int a = 5;
|
||||
cout << a << endl;
|
||||
podwoj1(a); // nie zmieni wartości poza funkcją
|
||||
cout << "a po podwojeniu kopią: " << a << endl;
|
||||
podwoj2(a); // zmieni wartość poza funkcją
|
||||
cout << "a po podwojeniu referencją: " << a << endl;
|
||||
}
|
||||
Reference in New Issue
Block a user