-4
如果元素不存在,返回false吗?我试图遍历一个矢量,并且只要它们存在就打印出每个已排序的元素。这里的代码片段,我一起工作:向量C++排序和打印
typedef struct {
string Name;
map<string,string> Numbers;
} Person
bool ComparebyAlpha(const Person &person1, const Person &person2) {
return person1.Name < person2.Name;
}
voic print_Contacts(vector <Person> Contacts) {
sort(Contacts.begin(), Contacts.end(), ComparebyAlpha);
int num = 0;
while (Contacts[num]) {
cout << Contacts[num].Name;
num++;
}
}