I am writing a birthday calendar with a multiset of birthday objects. My comparison function isn't sorting right and I can't search for a b-day by name.
class CompareName
{
public:
bool operator()(Birthday* a,Birthday *b)
{
if(a->getLastName()==b->getLastName() && a->getFirstName() != b->getFirstName())
return( a->getFirstName() < b->getFirstName());
else
return (a->getLastName()<b->getLastName());
}
This is my comparison function. I am wanting to be able to search the database by birthday or partial birthday and whole name. I cant get the search by name part working.
void MultiSet::searchByName( Birthday *a)
{
NameSet::iterator result;
result=nameSet.find(a);
if(result!=nameSet.end())
(*result)->print();
}
I have already used a type def for the multiset and have used it in my definition to include the object functor, but have left it out of this code excerpt for brevity.