home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_11_03
/
1103096b
< prev
next >
Wrap
Text File
|
1993-01-05
|
669b
|
34 lines
// 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
*/