title: Passing a vector by reference and changing its values in a range-based for loop?
body: <p>I'm trying to change the values of a vector by doing something similar to the following function:</p>
  
  <pre><code>vector&lt;int&gt; Question2_Part3(vector&lt;int&gt; &amp;v){
  
      for(auto elem : v){
          elem *= 2;
          cout &lt;&lt; elem &lt;&lt; " ";
      }
      cout &lt;&lt; "\n" &lt;&lt; endl;
  
      return v;
  }
  </code></pre>
  
  <p>Is this possible? I know that in my for loop, it is the value of <code>elem</code> that is changing. Can I have the same output while also changing the values in <code>v</code> and still use a range-based for loop?</p>