C++日期类.docVIP

  • 7
  • 0
  • 约2.27千字
  • 约 3页
  • 2018-05-25 发布于河南
  • 举报
C日期类

C++日期类 Date ,实现日期的设置和输出 类包括私有数据成员 year, month, day; 公有成员函数实现以下功能: 1)设置时间,并对该时间的有效性进行检测 2)输出时间,按mm/ dd / yyyy方式打印 3)判断该日期是一年的第几天 4)判断该日期是星期几 #include iostream #include string using namespace std; class Date { private: int Year, Month, Day; public: Date () { Year = Month = Day = 0; } Date (int Y, int M, int D) { Year = Y; Month = M; Day = D; } inline bool IsLeap () const { return ((this-Year % 4 == 0) (this-Year % 100 != 0) || (this-Year % 400 == 0)); } bool IsTrue (const Date d); inline void SetDate (int Y, int M, int D) { Year = Y; Month = M; Day = D; } int Cal

文档评论(0)

1亿VIP精品文档

相关文档