Listing 5. Data type methods.
class Date{
int month,day,year;//private data members
public:
Date(int mo,int da,int yr);//public constructor
void Display();//display the date
void AdjustMonth(int m);// +/- m months
int DayOfWeek();//return 0-6 = Sun-Sat
// --- arithmetic operators
Date operator+(int n);
Date operator-(int n);
int operator-(Date &dt);//note the reference operator
// --- assignment operators
Date& operator=(Date &dt);
// --- relational operators
int operator==(Date &dt);
int operator!=(Date &dt);
int operator<(Date &dt);
int operator>(Date &dt);
};//note the required semicolon
|