专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > C++

编写一个Date类程序,用c++如何写

发布时间:2011-06-29 00:39:58 文章来源:www.iduyao.cn 采编人员:星星草
编写一个Date类程序,用c++怎么写啊
跪求,程序编写
题目:定义一个满足如下要求的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;
}
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: