(1)
name = new char[strlen(n + 1)];
strcpy(name, n);
address = new char[strlen(add + 1)];
strcpy(address, add);
city = new char[strlen(ct + 1)];
strcpy(city, ct);
code = new char[strlen(cd + 1)];
strcpy(code, cd);
(2)
cout << "name: " << name << end;;
cout << "address: " << address << end;;
cout << "city: " << city << end;;
cout << "code: " << code << end;;
(3)
delete [] name;
name = new char[strlen(nm + 1)];
strcpy(name, nm);
不知道你这个问题是否已经解决, 如果还没有解决的话:(1)修改 getDaysWorked,使其调用日期类中重载的减号运算符。
(2)添加一个静态成员函数,调用日期类中重载的“>”运算符,通过比较
雇佣日期,在雇员对象数组中,找出工作年限最长的雇员。该函数的说明如下:
/*
*参数employees[]是雇员对象的数组;n是雇员对象数组的元素个数
*返回值:工作年限最长的雇员对象的引用
*/
static const Employee& getMostFaith(const Employee employees[], int n);