Source of date3.h


  1: // Filename: DATE3.H
  2: // Purpose:  Specification file for a simple Date class.

  4: class Date
  5: {
  6: public:
  7:     Date();
  8:     // Default constructor
  9:     // Pre:  none
 10:     // Post: month == 1  and  day == 1  and  year == 1970
 11:     //       and *messagePtr == "No message ..."

 13:     Date(/* in */ int         newMonth,
 14:          /* in */ int         newDay,
 15:          /* in */ int         newYear,
 16:          /* in */ const char* messageString);
 17:     // Constructor
 18:     // Pre:      1 <= newMonth <= 12
 19:     //       and 1 <= newDay   <= maximum number of days in newMonth
 20:     //       and 1970 <= newYear
 21:     //       and messageString is initialized
 22:     // Post: New class object is constructed with a date of newMonth, 
 23:     //       newDay, newYear and the message string in messageString.

 25:     void Display() const;
 26:     // Pre:  self is initialized.
 27:     // Post: Date and message have been output in the form
 28:     //       month day, year       message
 29:     //       in which the name of the month is displayed as a string,
 30:     //       and the message string is displayed on the line beneath
 31:     //       the date.

 33:     ~Date();
 34:     // Destructor
 35:     // Pre:  self is initialized.
 36:     // Post: Message string pointed to by messagePtr has been deleted.

 38:     void InsertXX();
 39:     // Used only for pedagogical reasons to help show that only a 
 40:     // "shallow" copy of an object has been made.
 41:     // Pre:  self has been initialized with a message of size <= 2.
 42:     // Post: The first two characters of the message pointed to by
 43:     //       messagePtr have been changed to 'X'.

 45: private:
 46:     int   day;
 47:     int   month;
 48:     int   year;
 49:     char* messagePtr;
 50: };