Created
September 19, 2012 11:09
-
-
Save trevorrjohn/3749088 to your computer and use it in GitHub Desktop.
Pass by reference
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
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