home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_11_03
/
1103099a
< prev
next >
Wrap
Text File
|
1993-01-05
|
674b
|
32 lines
// tdate6.cpp:
#include <stdio.h>
#include "date6.h"
main()
{
Date d1(1,1,1970), d2(12,8,1992);
Date result = d1 - d2;
printf("years: %d, months: %d, days: %d\n",
result.get_year(),
result.get_month(),
result.get_day());
result = d2 - d1;
printf("years: %d, months: %d, days: %d\n",
result.get_year(),
result.get_month(),
result.get_day());
int test = d1 - d2 == -(d2 - d1);
printf("d1 - d2 == -(d2 - d1)? %s\n",
test ? "yes" : "no");
return 0;
}
/* OUTPUT
years: -22, months: -11, days: -7
years: 22, months: 11, days: 7
d1 - d2 == -(d2 - d1)? yes
*/