– Read chapter 8 – Derived Classes, and do... page 168:

advertisement
–
Read chapter 8 – Derived Classes, and do the following exercise, taken from chapter 8
page 168:
Consider a Year class which divides the days in a year into work days and off
days. Because each day has a binary value, Year is easily derived from BitVec (for
definition of class BitVec, please take a look at page 144 of chapter 8 of
CppEssentials.pdf):
enum Month {
Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec
};
Class Year : public BitVec {
Public:
Year
(const short year);
Void Workday (const short day); // set day as work day
Void OffDay (const short day); // set day as off day
Bool working (const short day); // true if a work day
Short Day (const short day,
// convert date to day
const Month month, const short year);
Protected:
short year;
// calendar year
};
Days are sequentially numbered from the beginning of the year, starting at 1 for January
1 . Complete the Year class by implementing its member functions.
st
Download