Listing 5 Uses the Date relational operators

// tdate5.cpp

#include <stdio.h>
#include <stdlib.h>
#include "date5.h"

void compare_dates(const Date& d1, const Date& d2)
{
   char *compstr = (d1 < d2) ? "precedes" :
     ((d1 > d2) ? "follows" : "equals");

   printf("%d/%d/%d %s %d/%d/%d\n",
     d1.get_month(),d1.get_day(),d1.get_year(),
     compstr,
     d2.get_month(),d2.get_day(),d2.get_year());
}

main()
{
   Date d1(1,1,1970);
   compare_dates(d1,Date(10,1,1951));
   compare_dates(d1,Date(1,1,1970));
   compare_dates(d1,Date(12,31,1992));
   return 0;
}

/* OUTPUT

1/1/1970 follows 10/1/1951
1/1/1970 equals 1/1/1970
1/1/1970 precedes 12/31/1992
*/

// End of File