谁会用C++编写此程序,跪求!!!谢谢 定义一个日期类Date

来源:百度知道 编辑:UC知道 时间:2024/05/21 14:18:49
定义一个日期类Date,其中包括,年,月,日三个数据成员,有构造函数,设置日期函数,显示日期函数,拷贝构造函数.编写主函数测试类的功能.
必须用C++做谢谢

程序见下:

#include<iostream.h>

class CDateINfo
{
public:
//默认的构造函数
CDateINfo()
{
cout<<"调用默认的构造函数\n";
m_nYear=2000;
m_nMonth=1;
m_nDay=1;
};
//有参数的构造函数
CDateINfo(int nYear,int nMonth,int nDay)
{
cout<<"调用带参数的构造函数\n";
m_nYear=nYear;
m_nMonth=nMonth;
m_nDay=nDay;
}
//拷贝构造函数
CDateINfo(CDateINfo &data)
{
cout<<"调用拷贝构造函数\n";
m_nYear=data.m_nYear;
m_nMonth=data.m_nMonth;
m_nDay=data.m_nDay;
};
~CDateINfo(){};
//设置日期
void SetDateINfo(int nYear,int nMonth,int nDay)
{
m_nYear=nYear;
m_nMonth=nMonth;
m_nDay=nDay;
};
//打印日期
void PrintDateINfo()
{
cout<<"年:"<<m_nYear<<endl;
cout<<"月:"<<m_nMonth<<endl;
cout<<"日:&