object file
By: j00s | Date: Sep 20 2007 02:26 | Format: C++ | Expires: never | Size: 993 B | Hits: 1213
- // functions
- #include <iostream>
- #include "Date.h"
- const int Date::days[] =
- { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
- //constructor
- Date::Date ( int m, int d, int y )
- {
- setDate ( m, d, y );
- }
- void Date::setDate( int mm, int dd, int yy )
- {
- month = ( mm >= 1 && mm <= 12 ) ? mm : 1;
- year = ( yy >= 1900 && yy <= 2100 ) ? yy : 1900;
- }
- Date &Date::operator++()
- {
- helpIncrement();
- return *this;
- }
- Date Date::operator++( int )
- {
- Date temp = *this;
- helpIncrement();
- return temp;
- }
- const Date &Date::operator+=( int additionalDays)
- {
- for (int i=0; i < additionalDays; i++ )
- helpIncrement();
- return *this;
- }
- void Date::helpIncrement()
- {
- if (month < 12 )
- {
- month++;
- day = 1;
- }
- else
- {
- year++;
- month=1;
- day=1;
- }
- }
- ostream &operator<<( ostream &output, const Date &d)
- {
- output << d.month << " " << d.day << " " << d.year;
- return output;
- }
Latest pastes
2 hours ago
1 days ago
1 days ago
2 days ago
2 days ago