/*********************** 09-1-S.TXT ************************** *********** Prof. Dr. B. Bartning ***************************/ // Classes POSSIBLE SOLUTIONS FOR EXERCISES (bcd) IN FILE 09-1B.CPP: ------------------------------------------------------------ For exercise (b) ---------------- Member function setDate must be made public. When used by both constructors, this change was not necessary because each member function (and with it, the constructors, too) has access to all members, also to the hidden ones. *************************************************************** For exercise (c) ---------------- Include in file 09-1.H (within the public part of the class definition): ------------------------------------------------- void plus1Day(); Include in file 09-1A.CPP: -------------------------- void Date::plus1Day() { if (++day>lastOfMonth()) { day=1; if (++month>12) { month=1; ++year; } } } *************************************************************** For exercise (d) ---------------- Include in file 09-1.H (within the public part of the class definition): ------------------------------------------------- void plusDays(int num); Include in file 09-1A.CPP: -------------------------- void Date::plusDays(int num) { if (num<0) return; // only for values >=0 day+=num; int last; while (day>(last=lastOfMonth())) { day-=last; if (++month>12) { month=1; ++year; } } } *************************************************************** Exercise (e): see files 09-1-S.H and 09-1A-S.CPP (see remark in exercise text) ********************************************************************