#include #include #include "Person.h" vector init(); ostream& operator <<(ostream& outs, Person &p); vector match(const vector people, bool f(const Person &p)); bool is_male(const Person &p); bool is_C(const Person &p); int main() { vector people = init(); vector males; vector cs; cout << "Males:" << endl; males = match(people, is_male); for (Person& p : males) cout << p << endl; cout << endl << "Last name starts with C:" << endl; cs = match(people, is_C); for (Person& p : cs) cout << p << endl; } vector init() { vector v; v.push_back(Person("Ron", "Mak", Gender::M)); v.push_back(Person("Marie", "Curie", Gender::F)); v.push_back(Person("Agatha", "Cristie", Gender::F)); v.push_back(Person("Barack", "Obama", Gender::M)); return v; } ostream& operator <<(ostream& outs, Person &p) { outs << " {" << "first=" << p.first << ", last=" << p.last << ", gender=" << (p.gender == Gender::F ? "F" : "M") << "}"; return outs; } vector match(const vector people, bool f(const Person &p)) { vector matches; for (const Person& p : people) if (f(p)) matches.push_back(p); return matches; } bool is_male(const Person &p) { return p.gender == Gender::M; } bool is_C(const Person &p) { return p.last[0] == 'C'; }