// Project Employee // File main.cpp // Illustrates inheritance and virtual // methods. Recall that all methods in // Java are virtual. #include "Executive.h" int main() { Person x("Scott", 'M', 34); x.display(); cout << endl; Employee y("Mary", 'F', 21, 12342, 89000); y.display(); cout << endl; Executive z("Alice", 'F', 40, 32653, 150000, 50000); z.display(); cout << endl; Person *a[5]; a[0] = new Employee("Jane", 'F', 38, 23473, 75000); a[1] = new Executive("Tom", 'M', 31, 18374, 161000, 65000); a[2] = new Employee("Jane", 'F', 43, 84736, 81000); a[3] = new Person("Tracy", 'F', 21); a[4] = new Executive("Wayne", 'M', 29, 74639, 95000, 30000); for(int i = 0; i <= 4; i++) { cout << "Index = " << i << endl; a[i] -> display(); cout << endl; } return EXIT_SUCCESS; } // Output: // name = Scott // gender = M // age = 34 // // name = Mary // gender = F // age = 21 // id = 12342 // salary = 89000 // // name = Alice // gender = F // age = 40 // id = 32653 // salary = 150000 // bonus = 50000 // // Index = 0 // name = Jane // gender = F // age = 38 // id = 23473 // salary = 75000 // // Index = 1 // name = Tom // gender = M // age = 31 // id = 18374 // salary = 161000 // bonus = 65000 // // Index = 2 // name = Jane // gender = F // age = 43 // id = 84736 // salary = 81000 // // Index = 3 // name = Tracy // gender = F // age = 21 // // Index = 4 // name = Wayne // gender = M // age = 29 // id = 74639 // salary = 95000 // bonus = 30000