Comp 1572, Winter 2002 Pencil-and-Paper Assignment 6 Assigned Friday, February 22, 2002 Due Friday, March 1, 2002 (At the beginning of class) ============================================================================ solutions ============================================================================ 1. Both constructor definitions cannot exist in the same class, because the first definition has default values, and thus *is already* a default constructor. There is an ambiguity - if no parameters are passed to the constructor, the compiler wouldn't know which function to call. So this is not allowed. 2. There are many solutions. Here is one: char * search_for_char(char *arr, char key) { char *p; for (p=arr; *p != 0; p++) { if (*p == key) return p; } return 0; // not found! } 3. Given the following class class Employee { public: Employee(); //default constructor Employee(const char *, const char *); // constructor ~Employee(); //destructor const char *getFirstName() const; // return first name const char *getLastName() const; // return last name void setLastName(char *); // set employee last name void setFirstName(char *); // set employee first name private: char *firstName; char *lastName; }; Write a program that will ask the user how many employees there are, dynamically allocate an array of Employees of the appropriate size, input from the user the data for each employee and update the Employees in the array, traverse the array and display the data, delete the dynamically allocated memory, and exit. int main() { int numemp; Employee *elist; cout << "How many employees? "; cin >> numemp; char firstname[80], lastname[80]; elist = new Employee[numemp]; for (i=0; i < numemp; i++) { cout << "Input first and last name of employee number " << i << ": "; cin >> firstname >> lastname; elist[i].setFirstName(firstname); elist[i].setLastName(lastname); } for (i=0; i setTime(i1,i2,i3); } proxy_for_time::printMilitary() const { ptr->printMilitary(); } proxy_for_time::printStandard() const { ptr->printStandard(); }