请教一个二元谓词问题...........
#include <set>#include <string>#include <iostream>using namespace std;enum MenuOptionSelection{ InsertContactsetEntry = 0, DisplayEntries = 1, FindNumber = 2, EraseEntry = 3, FindName = 4, QuitApplication = 5};struct ContactItem{ string strContactsName; string strPhoneNumber; ContactItem(const string &strName,const string &strNumber) { strContactsName = strName; strPhoneNumber = strNumber; } bool operator== (const ContactItem &itemToCompare) const { return (itemToCompare.strContactsName == this->strContactsName); } bool operator< (const ContactItem &itemToCompare) const { return (this->strContactsName < itemToCompare.strContactsName); }};struct FindContactGivenNumber{ bool operator() (const ContactItem &item1,const ContactItem &item2) const { return (item1.strPhoneNumber < item2.strPhoneNumber); }};int ShowMenu(){ cout<<"***What would you like to do next?***"<<endl<<endl; cout<<"======================================="<<endl; cout<<"Enter 0 to feed a name and phone number"<<endl; cout<<"Enter 1 to Display all entries"<<endl; cout<<"Enter 2 to find an entry"<<endl; cout<<"Enter 3 to erase an entry"<<endl; cout<<"Enter 4 to find name with phone number"<<endl; cout<<"Enter 5 to quit this application"<<endl; cout<<"======================================="<<endl<<endl; cout<<"> "; int nOptionSelected; cin>>nOptionSelected; cout<<endl; return nOptionSelected;}ContactItem GetContactInfo(){ cout<<"***Feed contact information***"<<endl; string strName; cout<<"Please enter the person's name"<<endl; cout<<"> "; cin>>strName; string strPhoneNumber; cout<<"Please enter "<<strName<<"'s phone number"<<endl; cout<<"> "; cin>>strPhoneNumber; return ContactItem(strName,strPhoneNumber);}void DisplayContactset(const set<ContactItem> &setContacts){ cout<<"***Displaying contact information***"<<endl; cout<<"There are "<<setContacts.size()<<" entries:"<<endl; set<ContactItem>::const_iterator iContact; for (iContact = setContacts.begin() ;iContact != setContacts.end() ;++iContact) { cout<<"Name: '"<<iContact->strContactsName; cout<<"' Number: '"<<iContact->strPhoneNumber<<"'"; cout<<endl; } cout<<endl;}void FindContactNumber(const set<ContactItem> &setContacts){ cout<<"***Find a contact***"<<endl; cout<<"Whose number do you wish to find?"<<endl; cout<<"> "; string strName; cin>>strName; set<ContactItem>::const_iterator iContactFound = setContacts.find(ContactItem(strName,"")); if (iContactFound != setContacts.end()) { cout<<strName<<" is reachable at number: "; cout<<iContactFound->strPhoneNumber<<endl; } else { cout<<strName<<" was not found in the contacts list"<<endl; } cout<<endl;}void FindContactName(const set<ContactItem> &setContacts){ cout<<"***Find a contact***"<<endl; cout<<"Whose name do you wish to find?"<<endl; cout<<"> "; string strNumber; cin>>strNumber; set<ContactItem>::const_iterator iContactFound = setContacts.find(ContactItem("",strNumber)); if (iContactFound != setContacts.end()) { cout<<strNumber<<" is reachable at number: "; cout<<iContactFound->strContactsName<<endl; } else { cout<<strNumber<<" was not found in the contacts list"<<endl; } cout<<endl;}void EraseContact(set<ContactItem> &setContacts){ cout<<"***Erase a contact***"<<endl; cout<<"Whose number do you wish to erase?"<<endl; cout<<"> "; string strName; cin>>strName; size_t nErased = setContacts.erase(ContactItem(strName,"")); if (nErased > 0) cout<<strName<<"'s contact information erased."<<endl; else cout<<strName<<" was not found!"<<endl; cout<<endl;}int main(){ set<ContactItem> setContacts; int nUserSelection; string strInput; while ((nUserSelection = ShowMenu()) != (int)QuitApplication) { switch (nUserSelection) { case InsertContactsetEntry: setContacts.insert(GetContactInfo()); cout<<"Contacts set updated!"<<endl<<endl; break; case DisplayEntries: DisplayContactset(setContacts); break; case FindNumber: FindContactNumber(setContacts); break; case EraseEntry: EraseContact(setContacts); DisplayContactset(setContacts); break; case FindName: FindContactName(setContacts); break; case QuitApplication: break; default: cout<<"Invalid input '"<<nUserSelection; cout<<"'. Please choose an option between 0 and 4"<<endl<<endl; break; } } cout<<"Quiting! Bye!"<<endl<<endl; char response; cin>>response; return 0;}