Skip to content

Instantly share code, notes, and snippets.

@kkabdol
Last active May 18, 2016 09:28
Show Gist options
  • Select an option

  • Save kkabdol/e6bce568a9cd20b0b85e45ed21a76f73 to your computer and use it in GitHub Desktop.

Select an option

Save kkabdol/e6bce568a9cd20b0b85e45ed21a76f73 to your computer and use it in GitHub Desktop.
Pointer versus References example
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