写一个日期类 有三个参数的构造函数 默认值
是2014年5月8日。要求可以显示日期 还可以
设置日期 日期的默认值是 2014年1月1日 。
还要求 头文件 和实现文件分离。

是2014年5月8日。要求可以显示日期 还可以
设置日期 日期的默认值是 2014年1月1日 。
还要求 头文件 和实现文件分离。
date.cpp 实现date.h 中Date的成员函数内容
/*
* int year,month,day;
* */
#include <iostream>
#include <iomanip>
#include "date.h"
using namespace std;
Date::Date(int year,int month,int day):year(year),month(month),day(day){
}
void Date::show(){
cout << setfill('0') << setw(4) << year << "年" << setw(2) << month << "月" << setw(2) << day \
<< "日" << endl;
}
void Date::setDate(int year,int month,int day){
this->year = year;
this->month = month;
this->day = day;
}
date.h 声明时间类和时间的成员函数#ifndef __DATE_H__
#define __DATE_H__
class Date{
private:
int year,month,day;
public:
Date(int year = 2014,int month = 5,int day = 8);
void show();
void setDate(int year = 2014,int month = 1,int day = 1);
};
#endif
mian.c
#include "date.h"
int main(void){
Date today;
today.show();
today.setDate(2014,8,15);
today.show();
today.setDate();
today.show();
return 0;
}