Sorry, I know there are questions where people ask how to remove duplicates, but I thought this warranted a new thread since there is something weird coming out of my compiler.
vector<string> removeDuplicates(vector<string> vector)
{
for (vector<string>:: const_iterator it = vector.begin(); it != vector.end(); ++it)
{
for (vector<string>:: const_iterator sit = vector.begin(); sit != vector.end(); ++sit)
{
if(it != sit)
{
if(*it == *sit)
{
vector.erase(it);
}
}
}
}
return vector;
}
I don't understand why it's giving me errors. I am kinda new to C++, so the question might sound kinda dumb. Is it because I am looping on the same vector?