Help with finding the intersection of 2 strings
Hi,
I'm just about done with implemting code for procurring the intersection of 2 strings and returns a 3rd string that is the intersection. However, i have some errors occuring, refer to the code below.
Any help would be appreciated,
thanks,
I
Code:
StringSet StringSet::set_intersection(set1 set2)
{
// record chars that have already been found to intersect so that we don't
// add them to result more than once
int hits[256];
// memset(hits, 0, sizeof(hits));
string result;
char cur;
for ( int i = 0; i < contents.size(); i++) {
cur = contents[i]; //ERROR OCCURS HERE cannot convert `std::basic_string<char, std::char_traits<char>, std::allocator<char> >' to `char' in assignment
if (contents.find(cur) != string::npos)//ERROR OCCURS HERE, CANNOT USE "FIND FUNCTION" {
if (hits[(int)cur] == 0) {
// found new char
hits[(int)cur] = 1;
result += cur;
} else {
// already found char so don't add to result
}
}
}
return result; //ERROR conversion from `std::string' to non-scalar type `StringSet' requested
}