编写一个Date类程序,用c++如何写
编写一个Date类程序,用c++怎么写啊
跪求,程序编写
题目:定义一个满足如下要求的Date类:用日/月/年的格式输出日期;可运行在日期上加一天操作;设置日期操作。
------解决方案--------------------
跪求,程序编写
题目:定义一个满足如下要求的Date类:用日/月/年的格式输出日期;可运行在日期上加一天操作;设置日期操作。
------解决方案--------------------
- C/C++ code
class Date { private: int year; int month; int day; public: Date(int y, int m, int d); void AddOne(); void SetDate(int y, int m, int d); } Date::Date(int y, int m, int d) { this.year = y; this.month = m; this.day = d; } Date:AddOne() { this.day += 1; // 这里根据天数和月份做判断 } Date::SetDate(int y, int m, int d) { this.year = y; this.month = m; this.day = d; }