#include #include #include using namespace std; class person { public: string fname, lname; person(string f, string l) { fname = f; lname = l; }; void print() { cout << fname << " " << lname << "\n"; } }; vector people; void add_person(person * p) { people.push_back(p); } void list_people() { for (int i = 0; i < people.size(); i += 1) people[i]->print(); } person * find_person(string name) { for (int i = 0; i < people.size(); i += 1) if (people[i]->fname == name || people[i]->lname == name) return people[i]; return NULL; } int main() { add_person(new person("Mary", "Marlowe")); add_person(new person("Dennis", "Dog")); add_person(new person("Eric", "Earwig")); add_person(new person("Tammy", "Teapot")); add_person(new person("Francine", "Frogge")); add_person(new person("Geoffrey", "Georaffe")); add_person(new person("Lolita", "Lambchop")); add_person(new person("Indiana", "Impediment")); add_person(new person("Germania", "Gastropod")); add_person(new person("Olivia", "Ointment")); string cmd; while (true) { cout << "> "; cin >> cmd; if (cmd == "list") list_people(); else if (cmd == "find") { string n; cin >> n; person * e = find_person(n); if (e == NULL) cout << "Not found\n"; else e->print(); } /* else if (cmd == "raise") { string n; cin >> n; double pct; cin >> pct; person * e = find_employee(n); e->salary *= 1.0 + pct / 100.0; } */ else if (cmd == "exit") break; else cout << "command '" << cmd << "' not recognised\n"; } }