Advertisement
Guest User

date_class.h

a guest
Dec 21st, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.31 KB | None | 0 0
  1. #pragma once
  2.  
  3. class Date {
  4.     friend const long int count_days_between_dates(const Date &, const Date &);
  5.  
  6.     friend const bool compare_dates(const Date &, const Date &);
  7.  
  8. private:
  9.     static const short int _firstYear = 1901; //начало времён
  10.     short int m_year, m_month, m_day;
  11.  
  12.     const bool is_leap_year(const short int &) const;
  13.  
  14.     const short int days_in_year(const short int &) const;
  15.  
  16.     const short int days_in_month(const short int &, const short int &) const;
  17.  
  18.     void define_date(long int) const; //определение даты по кол-ву дней, начиная с 1901
  19.    
  20.     const long int count_days() const; //подсчёт дней между 1901 и данной датой
  21.  
  22. public:
  23.     Date();
  24.  
  25.     Date(const short int &, const short int &, const short int &);
  26.  
  27.     Date(const Date &);
  28.  
  29.     ~Date() = default;
  30.  
  31. //    long int operator-(const Date &);
  32. //
  33. //    long int operator+(const Date &);
  34.  
  35.     const bool operator<(const Date &) const;
  36.  
  37.     const bool operator>(const Date &) const;
  38.  
  39.     const bool operator<=(const Date &) const;
  40.  
  41.     const bool operator>=(const Date &) const;
  42.  
  43.     const bool operator==(const Date &) const;
  44.  
  45.     const bool operator!=(const Date &) const;
  46.  
  47.     void print_date() const; //вывод даты на экран
  48.     void set_date(const short int &, const short int &, const short int &); //изменение даты
  49.     const bool is_leap_year() const; //идентификация високосного года
  50.     const short int days_in_year() const; //подсчёт дней в году
  51.     const short int days_in_month() const; //подсчёт дней в месяце
  52.     const bool correct_date() const; //проверка правильности введёной даты
  53.     void next_day() const; //определение следующего дня
  54.     void previous_day() const; //определение предыдущего дня
  55.     void future_date(long int) const; //определение будущей даты через n дней от данной даты
  56.     void past_date(long int) const; //определение прошлой даты за n дней от данной даты
  57.     friend void sort_dates(Date *, const int &); //сортировка массива дат
  58. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement