home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / C++-7 / DISK4 / SAMPLES / CPPTUTOR / DATE.H$ / DATE
Encoding:
Text File  |  1991-12-11  |  1.4 KB  |  59 lines

  1. // DATE.H
  2.  
  3. // This is the final version of an example class from Chapter 4 of the
  4. //     C++ Tutorial. This class demonstrates an overloaded constructor,
  5. //     inline member functions, and const member functions.
  6.  
  7. #if !defined( _DATE_H_ )
  8.  
  9. #define _DATE_H_
  10.  
  11. class Date
  12. {
  13. public:
  14.    Date();                          // Default constructor
  15.    Date( int mn, int dy, int yr );  // Constructor
  16.                                     // Member functions:
  17.    int getMonth() const;            //   Get month - read only
  18.    int getDay() const;              //   Get day - read only 
  19.    int getYear() const;             //   Get year - read only
  20.    void setMonth( int mn );         //   Set month
  21.    void setDay( int dy );           //   Set day
  22.    void setYear( int yr );          //   Set year
  23.    void display() const;            //   Print date - read only
  24.    ~Date();                         // Destructor
  25. private:
  26.    int month, day, year;            // Private data members
  27. };
  28.  
  29. // some useful functions
  30. inline int max( int a, int b )
  31. {
  32.     if( a > b ) return a;
  33.     return b;
  34. }
  35.  
  36. inline int min( int a, int b )
  37. {
  38.     if( a < b ) return a;
  39.     return b;
  40. }
  41.  
  42. inline int Date::getMonth() const
  43. {
  44.     return month;
  45. }
  46.  
  47. inline int Date::getDay() const
  48. {
  49.     return day;
  50. }
  51.  
  52. inline int Date::getYear() const
  53. {
  54.     return year;
  55. }
  56.  
  57. #endif  // _DATE_H_
  58.  
  59.