#include #include #include using namespace std; void log(string event, string description) { /* let's pretend this makes an official record in a file somewhere */ } class person { protected: string fname, lname, addr, phone; public: person(string f, string l, string a, string p) { fname = f; lname = l; addr = a; phone = p; } void print() { cout << fname << " " << lname << " of " << addr << ", phone " << phone << "\n"; } string get_name() { return fname + " " + lname; } string get_address() { return addr; } string get_phone() { return phone; } void change_name(string f, string l) { log("name change from ", fname + " " + lname + " to " + f + " " + l); fname = f; lname = l; } void change_address(string a) { log("address change for ", fname + " " + lname + " to " + a); addr = a; } void change_phone(string p) { log("phone change for ", fname + " " + lname + " to " + p); phone = p; } }; class employee: public person { protected: string dept; int salary; public: employee(string f, string l, string a, string p, string d, int s): person(f, l, a, p) { dept = d; salary = s; } void print() { cout << fname << " " << lname << " of " << addr << ", phone " << phone << " (" << dept << ", $" << salary << ")\n"; } void give_raise(double percent) { salary = (int)(salary * (1 + percent / 100)); } }; int main() { vector database; database.push_back(new person("Joe", "Ant", "123 Cat St", "3059990001")); database.push_back(new person("Jenny", "Ant", "123 Cat St", "3059990001")); database.push_back(new employee("Zoe", "Gnat", "864 Cat St", "4445556666", "Management", 120000)); database.push_back(new person("Amy", "Bat", "987 Dog Ave", "7860106734")); database.push_back(new person("Fred", "Horse", "66 Main St", "5552679742")); database.push_back(new person("Betty", "Thing", "456 Dog Ave", "2010012694")); database.push_back(new employee("Andy", "Goat", "7 Main St", "3002019736", "Hexagons", 45000)); database[2]->change_name("Amy", "Horse"); for (int i = 0; i < database.size(); i += 1) database[i]->print(); }