From bf493c07ed519cc3d41198a0720a5919f67f3ff0 Mon Sep 17 00:00:00 2001 From: Geoff Liu Date: Mon, 1 Dec 2014 21:39:49 -0700 Subject: Reassignment to reference doesn't cause error --- c++.html.markdown | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/c++.html.markdown b/c++.html.markdown index 9f357b08..5f80f26f 100644 --- a/c++.html.markdown +++ b/c++.html.markdown @@ -238,7 +238,10 @@ string& fooRef = foo; // This creates a reference to foo. fooRef += ". Hi!"; // Modifies foo through the reference cout << fooRef; // Prints "I am foo. Hi!" -fooRef = bar; // Error: references cannot be reassigned. +// Doesn't reassign "fooRef". This is the same as "foo = bar", and +// foo == "I am bar" +// after this line. +fooRef = bar; const string& barRef = bar; // Create a const reference to bar. // Like C, const values (and pointers and references) cannot be modified. -- cgit v1.2.3