Task: Update the previous exercise to create a child of the Person
class, called Staff
. This child class should have the functionality as illustrated in
Figure 3.28, “The Person
and Staff
class hierarchy.” that builds the basic functionality of the general person role in DCU.
The output of my version can be seen below, where the addPayRise()
method is called to
give a pay rise of 5%:
C:\Temp>Exercise2 Name: Derek Molloy Address: DCU, Glasnevin, D9 Telephone: 7005355 Creating Staff Member: Name: Derek Molloy Address: DCU, Glasnevin, D9 Telephone: 7005355 Office: S356 ID Number: 94971056 Salary: 12000 Euro Payrise of 5%: Name: Derek Molloy Address: DCU, Glasnevin, D9 Telephone: 7005355 Office: S356 ID Number: 94971056 Salary: 12600 Euro
Solution: My version can be seen in
Exercise2.cpp
. Please do not look at the solution until you
have had a good attempt at the exercise.
© 2006
Dr. Derek Molloy
(DCU).