Advanced Inheritance 547
16
30: };
31:
32: Employee::Employee():
33: itsFirstName(“”),
34: itsLastName(“”),
35: itsAddress(“”),
36: itsSalary(0)
37: {}
38:
39: Employee::Employee(char * firstName, char * lastName,
40: char * address, long salary):
41: itsFirstName(firstName),
42: itsLastName(lastName),
43: itsAddress(address),
44: itsSalary(salary)
45: {}
46:
47: Employee::Employee(const Employee & rhs):
48: itsFirstName(rhs.GetFirstName()),
49: itsLastName(rhs.GetLastName()),
50: itsAddress(rhs.GetAddress()),
51: itsSalary(rhs.GetSalary())
52: {}
53:
54: Employee::~Employee() {}
55:
56: Employee & Employee::operator= (const Employee & rhs)
57: {
58: if (this == &rhs)
59: return *this;
60:
61: itsFirstName = rhs.GetFirstName();
62: itsLastName = rhs.GetLastName();
63: itsAddress = rhs.GetAddress();
64: itsSalary = rhs.GetSalary();
65:
66: return *this;
67: }
68:
69: int main()
70: {
71: cout << “Creating Edie...\n”;
72: Employee Edie(“Jane”,”Doe”,”1461 Shore Parkway”, 20000);
73: Edie.SetSalary(20000);
74: cout << “Calling SetFirstName with char *...\n”;
75: Edie.SetFirstName(“Edythe”);
76: cout << “Creating temporary string LastName...\n”;
77: String LastName(“Levine”);
78: Edie.SetLastName(LastName);
79:
80: cout << “Name: “;
LISTING16.3 continued