title: Modify elements of vector (by value, by reference) Function C++
body: <p>I have a function where I have to modifiy the values of a vector.
  is it a good practice in C++ to return the vector?</p>
  
  <h2>Function 1:</h2>
  
  <pre><code>vector&lt;string&gt; RemoveSpecialCharacters(vector&lt;string&gt; words)
  {
      for (vector&lt;string&gt;::iterator it=words.begin(); it!=words.end(); )
      {
          if(CheckLength(*it) == false)
          {
              it = words.erase(it);
          }
          else{
              ++it;
          }
      }//end for
  
      return words;
  }
  </code></pre>
  
  <h2><strong>Function 2:</strong></h2>
  
  <pre><code>void RemoveSpecialCharacters(vector&lt;string&gt; &amp; words)
  {
      for (vector&lt;string&gt;::iterator it=words.begin(); it!=words.end(); )
      {
          if(CheckLength(*it) == false)
          {
              it = words.erase(it);
          }
          else{
              ++it;
          }
      }//end for
  }
  </code></pre>