Last active
May 18, 2016 09:28
-
-
Save kkabdol/e6bce568a9cd20b0b85e45ed21a76f73 to your computer and use it in GitHub Desktop.
Pointer versus References example
This file contains hidden or 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
| string s1("Nancy"); | |
| string s2("Clancy"); | |
| string& rs = s1; // rs refers to s1 | |
| string* ps = &s1; // ps points to s1 | |
| rs = s2; // rs still refers to s1, but s1's value is now "Clancy" | |
| ps = &s2 // ps now points to s2; s1 is unchanged |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment