“++”运算符重载,实现对日期对象的日子加1的功能,若日期类对象d1为2021.5.13,则++t1后,t1为2021.5.14
为了实现的方便,我们假定每月都是30天,年份进位暂不必实现。
2021 5 13
2021.5.14
#include<iostream> using namespace std; class Date { private: int year, month, day; public: Date(int y=0, int m=0, int d=0) : year(y), month(m), day(d) {} void show_date(); Date operator++(); }; //pdsu-c1 //pdsu-c1 int main() { int y, m, d; cin >> y >> m >> d; Date d1(y, m, d); //pdsu-c2 //pdsu-c2 return 0; }
Anything about this OnlineJudge, Please Contact Administrator. Click add QQ
OJ system based on HUSTOJ Project , UI based on Twitter Bootstrap
Copyright 2016 ACM算法攻关部cnt: 8363
关于网站改版