- 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
您可能关注的文档
最近下载
- CKDMBD定义分类治疗进展.pptx
- 第一批全额减免公路客运附加费农村客运车辆名单广州.doc VIP
- 第八章普通心理学语言.ppt VIP
- [教育学]普通心理学 语言.ppt VIP
- 普通心理学语言与思考.ppt VIP
- 普通心理学--语言.pptx VIP
- EMERSON艾默生 Guide Display Unit RDU 40 User´s Guide-TankRadar Rex Rosemount说明书用户手册.pdf
- 个人信用报告征信简版电子版PDF版2024年2月最新版带水印可编辑.pdf VIP
- 征信简版电子版PDF个人信用报告最新版2024年可编辑带水印模板.pdf VIP
- 青少年编程:NOIP CSP 初赛篇.pdf VIP
原创力文档

文档评论(0)