Here is the code that produces the error in g++ 4.6.3
for (int i = 0; i < strlen(chars); i++)
{
a.erase (remove(a.begin(), a.end(), chars[i]), a.end());
}
The error i get is
error: cannot convert 'std::basic_string<char>::iterator {aka __gnu_cxx::__normal_iterator<char*, std::basic_string<char> >}' to 'const char*' for argument '1' to 'int remove(const char*)'
The code runs perfectly well in code blocks 12.11.
You need
#include <algorithm>
And use std::remove
instead of remove
.
Otherwise it tries to use the remove
function which is useful to remove files and it accepts const char*
as parameter.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.