Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <vector>
- using namespace std;
- string exp1 = "";
- enum Months { Jan, Feb, March, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec};
- class Ddata {
- public:
- Ddata *ptr;
- Ddata() {
- day = 0;
- month = 0;
- year = 0;
- }
- Ddata(int Pday, Months Pmonth, int Pyear) {
- /*checkData(Pday, Pmonth, Pyear);*/
- day = Pday;
- month = Pmonth;
- year = Pyear;
- }
- ~Ddata() {
- } //деструктор
- Ddata(const Ddata &dat) :day(dat.day), month(dat.month), year(dat.year) {} //конструктор копирования
- Ddata operator=(Ddata *d1) {
- day = d1->day;
- month = d1->month;
- year = d1->year;
- return *this;
- }
- bool operator>(Ddata d1) {
- if (d1.day + d1.month + d1.year > day + month + year)
- return true;
- else return false;
- }
- Ddata operator*(int r) {
- day = r*day;
- return *this;
- }
- Ddata operator+(Ddata &d1) {
- day = d1.day + day;
- month = d1.month + month;
- year = d1.year + year;
- return *this;
- }
- Ddata &operator++() {
- this->day++;
- return *this;
- }
- Ddata operator++(int val) {
- Ddata p(*this);
- this->day++;
- return p;
- }
- friend std::ostream& operator<<(std::ostream& out, const Ddata &d1)
- {
- out << d1.day << "." << d1.month + 1 << "."<< d1.year;
- return out;
- }
- private:
- int day, month, year;
- };
- int main() {
- int d = 11;
- Months m = Jun;
- int y = 2019;
- Ddata mydata(d,m,y);
- Ddata sss = mydata++;
- cout << mydata << ' ' << sss;
- if (sss > mydata) cout <<"ya";
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement