Listing 3 Tests the compare member function

// tdate4.cpp

#include <stdio.h>
#include "date4.h"

void compare_dates(const Date& d1, const Date& d2)
{
   int compval = d1.compare(d2);
   char *compstr - (compval < 0) ? "precedes" :
     ((compval > 0) ? "follows" : "equals"};

   printf("%d/%d/%d %s %d/%d/%d\n",
     d1.get_month(),d1.get_day(0),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