Created
November 28, 2016 20:53
-
-
Save SteelPh0enix/3220b950a0a419467f41ac835ffb47e9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
//przykład funkcji z i bez referencji | |
//dwie poniższe funkcje robią dokładnie to samo, tylko jedna używa referencji a druga nie | |
void referencja(int &a) { | |
a *= a; | |
} | |
int nieReferencja(int a) { | |
return a*a; | |
} | |
int main() { | |
int a = 3; | |
std::cout << "Bez referencji: " << nieReferencja(a) << std::endl; | |
referencja(a); | |
std::cout << "Wartość a po użyciu funkcji z referencją: " << a << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment