Listing 12 Defines static members

// date8.h

// Forward declarations
class istream;
class ostream;

class Date
{
   int month;
   int day;
   int year;

   static int dtab[2][13];

public:
   // Constructors
   Date();         // Get today's date (see .cpp file)
   Date(int m, int d, int y)
     {month = m; day = d; year = y;}

   // Accessor Functions
   int get_month() const
     {return month;}
   int get_day() const
     {return day;}
   int get_year() const
     {return year;}

   Date operator-(const Date& d2) const;
   Date& operator-()
     {month = -month; day = -day; year = -year;
      return *this;}

   int compare(const Date&) const;

   // Relational operators
   int operator<(const Date& d2) const
     {return compare{d2) < 0;}
   int operator<=(const Date& d2) const
     {return compare(d2) <= 0;}
   int operator>(const Date& d2) const
     {return compare(d2) > 0;}
   int operator>=(const Date& d2) const
     {return compare(d2) >= 0;}
   int operator==(const Date& d2) const
     {return compare(d2) == 0;}
   int operator!=(const Date& d2) const
     {return compare(d2) != 0;}

   // Stream I/O operators
   friend ostream& operator<<(ostream&, const Date&);
   friend istream& operator>>(istream&, Date&);

   static int isleap(int y)
     {return y%4 == 0 && y%100 != 0 || y%400 == 0;}
};

// End of File