c++ 写一个DATE,包含年,月,日,写一个方法nestDay可将日期加一天,用循环测试.

来源:百度知道 编辑:UC知道 时间:2024/06/20 06:36:36
刚刚开始学习c++,大家帮帮忙.
希望那位大虾能写个代码,多谢.

如果自己用

TSystemTime CurrentTime; //系统时间
TDateTime DataTime;//日期时间
//读系统时间
GetLocalTime(&CurrentTime);
DataTime = SystemTimeToDateTime(CurrentTime);//转换
DataTime += 1.0;//加一天
DateTimeToSystemTime(DataTime,CurrentTime);//转换
//设置系统时间
SetLocalTime(&CurrentTime);

如果完成老师作业
include <stdio.h>

class Date
{
private:
int year;
int month;
int day;

public:
//构造函数
Date(int y,int m,int d)
{
year = y;
month = m;
day = d;
}
~Date(){} //析构函数
//考贝构造函数
Date(Date& da)
{
year = da.year;
month = da.month;
day = da.day;
}

//设置日期的函数
bool setDate(int y,int m,int d)
{
year = y;
month = m;
day = d;
return true;
}
//显示日期的函数
void getDate()
{
printf("%d-%d-%d"