RelationType SortedList::ComparedTo(string otherItem) const
{
if(str < listData ->info)
return LESS;
else if (otherItem > listData ->info)
return GREATER;
else
return EQUAL;
}
There are no errors here but when I tried to use this function in another function I get an error.
string SortedList::GetItem(string& item, bool& found)
{
bool moreToSearch;
Node* location;
location = listData;
found = false;
moreToSearch = (location != NULL);
while (moreToSearch && !found)
{
switch(item.ComparedTo(location -> info))
{
case GREATER:
location = location -> next;
moreToSearch = (location != NULL);
break;
case EQUAL:
found = true;
item = location -> info;
break;
case LESS:
moreToSearch = false;
break;
}//end switch
}//end while
return item;
}
I get a red line under item.ComparedTo that says Error: class "std::basic_string<char, std::char_traits<char>,std::allocator<char>>" has no member function Compared to.
Any ideas on how to fix this?

New Topic/Question
Reply



MultiQuote



|