summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorPushkar Sharma <thepsguy@icloud.com>2015-10-04 10:12:55 +0530
committerPushkar Sharma <thepsguy@icloud.com>2015-10-04 10:12:55 +0530
commit9bc553c46ce9b7154ec7c82451d71608f4beda82 (patch)
treee9804e3ea16cf2b377c07f406ffaee271a3f9b9a
parent9b46fe7e57bcf63785b67cdaffc49ff0d47d7476 (diff)
Update c++.html.markdown
Regarding issue #1216, Better explaining the Reference 'fooRef'.
-rw-r--r--c++.html.markdown6
1 files changed, 6 insertions, 0 deletions
diff --git a/c++.html.markdown b/c++.html.markdown
index 4acc1b9d..bbd2f9a9 100644
--- a/c++.html.markdown
+++ b/c++.html.markdown
@@ -245,7 +245,13 @@ cout << fooRef; // Prints "I am foo. Hi!"
// Doesn't reassign "fooRef". This is the same as "foo = bar", and
// foo == "I am bar"
// after this line.
+cout << &fooRef << endl; //Prints address of fooRef
fooRef = bar;
+cout << &fooRef << endl; //Prints address of fooRef, AGAIN
+cout << fooRef; // Prints "I am bar"
+
+//The address of fooRef remains the same, i.e. it is still referring to foo.
+
const string& barRef = bar; // Create a const reference to bar.
// Like C, const values (and pointers and references) cannot be modified.