title: C++ Using and returning References
body: <p>Looking at the following function:</p>
  
  <pre><code>std::string&amp; foo (std::string&amp; s)
  {
    s.erase(0.s.find_first_not_of(" \f\t\v\r\n");
    return s;
  }
  </code></pre>
  
  <p>When one passes in a string, it does modify the original string right? Why would you want to return the modified string when you are also modifying the original?</p>
  
  <p>Trying to better understand why someone might have coded this function this way? Well someone did do this so I am being asked why am I only doing the following:</p>
  
  <pre><code>std::string mystring = "    This is cool";
  foo(mystring);
  std::cout &lt;&lt; mystring &lt;&lt; std::endl;
  </code></pre>
  
  <p>and why I am not making use of the returned value?</p>