mirror of
https://github.com/szymon-jozef/ZUT-notatki.git
synced 2026-09-07 20:20:39 +02:00
16 lines
365 B
C++
16 lines
365 B
C++
#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;
|
|
}
|