I have two vectors and want to compare their contents (strings) but this does not work:
vector<string>inwords = getInWords();
vector<string>killwords = getKillWords();
vector<string>::iterator it;
vector<string>::iterator ut;
for(it = inwords.begin(); it < inwords.end(); it++){
for (ut = killwords.begin(); ut < killwords.end(); ut++) {
if (*ut == *it){
cout << "match" << endl;
}
}
}
I also tried the compare function:
if (killwords[u].compare(inwords[i]) == 0)
My guess is that I need to overload the == operator, but I am not sure how to do that. Would be nice if you could help me out, as my google searches have not really gotten me anywhere. Cheers!
For what you’re trying with your code you might want to use
std::find_first_of. If you’re trying to compare ranges for (un)equality you may want to look atstd::mismatchorstd::equal.For anything else you want to achieve you better be more specific.