Skip to content

Instantly share code, notes, and snippets.

@trevorrjohn
Created September 19, 2012 11:09
Show Gist options
  • Save trevorrjohn/3749088 to your computer and use it in GitHub Desktop.
Save trevorrjohn/3749088 to your computer and use it in GitHub Desktop.
Pass by reference
int main() {
int foo = 5;
bar(foo);
if(foo == 5) {
cout << "foo not changed" << endl;
}
passByReference(foo);
if(foo == 6) {
cout << "foo changed to 6" << endl;
}
}
void bar(int a){
a = 4;
}
void passByReference(int &b){
a = 6
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment