Skip to content

Instantly share code, notes, and snippets.

@SteelPh0enix
Created November 28, 2016 20:53
Show Gist options
  • Save SteelPh0enix/3220b950a0a419467f41ac835ffb47e9 to your computer and use it in GitHub Desktop.
Save SteelPh0enix/3220b950a0a419467f41ac835ffb47e9 to your computer and use it in GitHub Desktop.
#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