Vla_DOS

Date

Jul 9th, 2022
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Date {
  6.  
  7. private:
  8.  
  9.     int day;
  10.  
  11.     int month;
  12.  
  13.     int year;
  14.  
  15. public:
  16.  
  17.     Date();
  18.  
  19.     Date(int, int, int);
  20.  
  21.     Date(const Date&);
  22.  
  23.     ~Date() = default;
  24.  
  25.     bool operator ==(const Date object) {
  26.  
  27.         return ((this->day == object.day) && (this->month == object.month) && (this->year == object.year));
  28.  
  29.     }
  30.     void ReportDate(Date object1, Date object2) {
  31.         bool result = object1 == object2;
  32.         if (result == 1) {
  33.             cout << "Дати спiвпадають!";
  34.         }
  35.         else {
  36.             cout << "Дати не спiвпадають!";
  37.         }
  38.     }
  39. };
  40.  
  41.  
  42. Date::Date() {
  43.  
  44.     day = 1;
  45.  
  46.     month = 1;
  47.  
  48.     year = 2000;
  49.  
  50. }
  51.  
  52.  
  53. Date::Date(int day, int month, int year) {
  54.  
  55.     this->day = day;
  56.  
  57.     this->month = month;
  58.  
  59.     this->year = year;
  60.  
  61. }
  62.  
  63.  
  64. Date::Date(const Date& object) {
  65.  
  66.     this->day = object.day;
  67.  
  68.     this->month = object.month;
  69.  
  70.     this->year = object.year;
  71.  
  72. }
  73.  
  74.  
  75. int main() {
  76.     setlocale(0, "");
  77.  
  78.     Date d;
  79.  
  80.     d.ReportDate(Date(26, 05, 2022), Date(26, 06, 2022));
  81.     return 0;
  82. }
Advertisement
Add Comment
Please, Sign In to add comment