title: Using a C++11 Range for loop to Change the Characters in a string
body: <p>I read in <a href="https://rads.stackoverflow.com/amzn/click/com/0321714113" rel="nofollow noreferrer" rel="nofollow noreferrer">C++ Primer</a> :</p>
  
  <blockquote>
    <p>If we want to change the value of the characters in a string, we must define the
    loop variable as a reference type (§ 2.3.1, p. 50). Remember that a
    reference is just another name for a given object. <strong>When we use a
    reference as our control variable, that variable is bound to each
    element in the sequence in turn.</strong> Using the reference, we can change
    the character to which the reference is bound.   </p>
  </blockquote>
  
  <p>Further they give this code : </p>
  
  <pre><code>string s("Hello World!!!");
  // convert s to uppercase
  for (auto &amp;c : s)   // for every char in s (note: c is a reference)
      c = toupper(c); // c is a reference, so the assignment changes the char
  in s
  cout &lt;&lt; s &lt;&lt; endl;
  </code></pre>
  
  <blockquote>
    <p>The output of this code is HELLO WORLD!!!</p>
  </blockquote>
  
  <p>I also read : </p>
  
  <blockquote>
    <p><strong>There is no way to rebind a reference to refer to a different object</strong>.
    Because there is no way to rebind a reference, references must be
    initialized.</p>
  </blockquote>
  
  <p>Question : Won't this code cause rebinding each time the reference variable <code>c</code> is binded to next character of string s ?</p>
  
  <pre><code>for (auto &amp;c : s)   
      c = toupper(c); 
  </code></pre>