13 Employee(const char* n): name(n) {}
14 virtual std::string getTitle() { return getPosition() + " " + getName(); }
15 virtual std::string getName() { return name; }
16 virtual std::string getPosition() const { return "Employee"; }
17 virtual ~Employee() { printf("~Employee() @ %p\n", this); }
21 class Manager: public Employee {
23 Manager(const char* n): Employee(n) {}
24 virtual std::string getPosition() const { return "Manager"; }
29 std::vector<Employee*> list;
32 list.push_back(new Employee("Bob"));
33 list.push_back(new Employee("Jane"));
34 list.push_back(new Manager("Ted"));
36 void addEmployee(Employee *p) {
38 std::cout << "New employee added. Current employees are:" << std::endl;
39 std::vector<Employee*>::iterator i;
40 for (i=list.begin(); i!=list.end(); i++) {
41 std::cout << " " << (*i)->getTitle() << std::endl;
44 const Employee *get_item(int i) {
48 std::vector<Employee*>::iterator i;
49 std::cout << "~EmployeeList, deleting " << list.size() << " employees." << std::endl;
50 for (i=list.begin(); i!=list.end(); i++) {
53 std::cout << "~EmployeeList empty." << std::endl;