Sams Teach Yourself C++ in 21 Days

(singke) #1
22: void SetAddress(const String & address)
23: { itsAddress = address; }
24: void SetSalary(long salary) { itsSalary = salary; }
25: private:
26: String itsFirstName;
27: String itsLastName;
28: String itsAddress;
29: long itsSalary;
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: void PrintFunc(Employee);

550 Day 16


LISTING16.4 continued
Free download pdf