title: No matching member function for call to "erase"
body: <p>I try to call erase() function to remove whitespaces in string for function that converts string to integer. The same code works in main() but inside function it doesn't.How can I fix it?</p>
  
  <pre><code>int convert(const string &amp;line)
  {
  
  for (int i=0;i&lt;line.length();i++)
  {
      char wh=' ';
      if(line.find(wh))
          line.erase(find(line.begin(),line.end(),' '));
  
      //cout&lt;&lt;line[i];
  }
  
  if(line.length()==0)
      return 0;
  int a=line[line.length()-1]-'0';
  int b=convert(line.substr(0,line.length()-1))*10;
  return a+b; 
  }
  </code></pre>