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?
Function 1:
vector<string> RemoveSpecialCharacters(vector<string> words)
{
for (vector<string>::iterator it=words.begin(); it!=words.end(); )
{
if(CheckLength(*it) == false)
{
it = words.erase(it);
}
else{
++it;
}
}//end for
return words;
}
Function 2:
void RemoveSpecialCharacters(vector<string> & words)
{
for (vector<string>::iterator it=words.begin(); it!=words.end(); )
{
if(CheckLength(*it) == false)
{
it = words.erase(it);
}
else{
++it;
}
}//end for
}