home *** CD-ROM | disk | FTP | other *** search
- // 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
- */
-
-