I got the following from Meyer's More Effective C++:
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
I do not understand why one line dereferences the pointer an assigns to the address of s1, to "point to" s1:
string *ps = &s1;
yet another line doesn't de-reference the pointer to "point to" s2:
ps = &s2;
can someone help me out here? Its the fact two different conventions seem to be doing the same thing which is confusing me.