#include #include #include using namespace std; class person { protected: string fname, lname, address, phone; public: person(string f, string l, string a, string p); void relocate(string newa, string newp); virtual void print(); }; person::person(string f, string l, string a, string p): fname(f), lname(l), address(a), phone(p) { } void person::relocate(string newa, string newp) { address = newa; phone = newp; } void person::print() { cout << fname << " " << lname << ", of " << address << ", phone " << phone; } class employee: public person { protected: double salary; string position; public: employee(string f, string l, string a, string p, double sal, string pos); virtual void print(); }; void employee::print() { person::print(); cout << "\n position=" << position << ", $" << salary; } employee::employee(string f, string l, string a, string p, double sal, string pos): person(f, l, a, p), salary(sal), position(pos) { } class criminal: public person { protected: string crime; public: criminal(string f, string l, string a, string p, string c); virtual void print(); }; criminal::criminal(string f, string l, string a, string p, string c): person(f, l, a, p), crime(c) { } void criminal::print() { person::print(); cout << ", " << crime; } class banker: public criminal { protected: int embezzled; public: banker(string f, string l, string a, string p, int e); virtual void print(); }; banker::banker(string f, string l, string a, string p, int e): criminal(f, l, a, p, "fraud"), embezzled(e) { } void banker::print() { person::print(); cout << ", a banker"; } int main() { vector A; A.push_back(new person("Lavinia", "Leopard", "55 Frog St.", "4046662233")); A.push_back(new person("Jim", "James", "987 Horse Rd.", "7364536475")); A.push_back(new person("Joe", "Jones", "123 Cat St.", "3051112222")); A.push_back(new person("Jemimah", "Jones", "123 Cat St.", "3051112222")); A.push_back(new person("Jimmy", "Jones", "123 Cat St.", "3051234321")); A.push_back(new person("Jilly", "Jones", "123 Cat St.", "3053242315")); A.push_back(new person("Anathema", "Hamsoup", "234 Dog Av.", "3057651243")); A.push_back(new employee("Colin", "Nostril", "234 Dog Av.", "9765432124", 34500, "manager")); A.push_back(new employee("Evangelina", "Smith", "17 Ant St.", "7253981256", 64250, "designer")); A.push_back(new employee("Lumpy", "Morris", "550 Bee St.", "7352749812", 52000, "secretary")); A.push_back(new employee("Ravioli", "Johnson", "99 Bat St.", "6364858272", 57500, "typist")); A.push_back(new criminal("Knuckles", "Badman", "77 Dark Lane", "9875674532", "burglary")); A.push_back(new criminal("Basher", "McRough", "245 Dog St.", "8272636451", "assault")); A.push_back(new criminal("Murgatroyd", "Madd", "591 Eel Way", "3547852371", "murder")); A.push_back(new banker("Arthur", "Arthropod-Smythe", "3 Rich Road", "1426378491", 57000000)); A.push_back(new banker("Melinda", "Machiavelli", "1 1st St.", "9872436472", 72500000)); for (int i = 0; i < A.size(); i += 1) { cout << i << ": "; A[i]->print(); cout << "\n"; } }