Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef DATE_PRO_DATE_H
- #define DATE_PRO_DATE_H
- #include <iostream>
- using namespace std;
- class date {
- private:
- int day, month, year;
- int getWday();
- int *months_days;
- void init();
- void update_months_days();
- void increment();
- void decrement();
- public:
- date();
- date(date const& d);
- date(int d,int m, int y);
- date(int m, int y);
- date(int y);
- ~date(){
- delete[] months_days;
- }
- bool isBissextile();
- friend ostream &operator<<(ostream &out, date const& d);
- void PrintDate();
- date operator++(int); // post fix
- date operator--(int);
- date operator++(); // pre fix
- date operator--();
- date operator+(int d);
- date operator+=(int d);
- date operator-(int d);
- date operator-=(int d);
- bool operator==(date const& d);
- bool operator!=(date const& d);
- bool operator<(date const& d);
- bool operator<=(date const& d);
- bool operator>(date const& d);
- bool operator>=(date const& d);
- int operator-(date const& d);
- int getDay() const {
- return day;
- }
- void setDay(int day) {
- this->day = (day < 1) ? 1 : ( (day > months_days[month - 1]) ? months_days[month - 1] : day );
- }
- int getYear() const {
- return year;
- }
- void setYear(int year) {
- this->year = (year < 1) ? 1 : year; //cout << "1 \n";
- update_months_days(); //cout << "1 \n";
- setDay(day);
- }
- int getMonth() const {
- return month;
- }
- void setMonth(int month) {
- this->month = (month < 1) ? 1 : ( (month > 12) ? 12 : month );
- setDay(day);
- }
- };
- #endif //DATE_PRO_DATE_H
Advertisement
Add Comment
Please, Sign In to add comment