title: Replace a string from a vector of string C++
body: <p>I have a vector of string constructed using:</p>
  
  <pre><code>vector&lt;string&gt; names;
  names.push_back("Gates");
  names.push_back("Jones");
  names.push_back("Smith");
  names.push_back("Gates");
  </code></pre>
  
  <p>I want to replace "Gates" with "Bill", for every occurrence of "Gates".
  For this the easiest solution I know is to use the replace function from algorithm and use it as:</p>
  
  <pre><code>replace(names.begin(), names.end(), "Gates", "Bill");
  </code></pre>
  
  <p>But I am getting following error:</p>
  
  <pre><code> parameter type mismatch:incompatible types 'const char (&amp;)[6]' and 'const char[5]'. 
  </code></pre>
  
  <p>I can solve it using implicit type casting like this:</p>
  
  <pre><code>replace(names.begin(), names.end(), "Gates", (const char (&amp;)[6]) "Bill");
  </code></pre>
  
  <p>Can anyone explain what this error is, and better way to solve it or better way to do it. Or why do we need this type casting.</p>