这次日期类的实现呢,主要具备查某月的日历,日期加减天数后是哪一天,两个日期之间相差的天数。比如说:你想知道离开学的日子还有多少天啊,离我们找工作还有多少天呐,这个月的日历是什么样的啊都可以它来查询!
下面给出代码实现:
Date.h
#ifndef _DATE__H_
#define _DATE__H_
#include<cstdio>
#include<iostream>
using namespace std;
class Date
{
friend void PrintDate(int year,int month);
public:
Date(int year,int month,int day);
Date(const Date& d);
bool JudgeLeapyear(int year)const;
int SetDay(const Date& d); //设置每月的天数并返回是哪个月
Date operator+(int day); //日期加天数
Date operator-(int day); //日期减天数
int operator-(const Date& date); //日期减日期(相差天数)
int Week(int year,int month); //计算当前月的第一天是星期几
void Display();
bool operator==(const Date& d);
bool operator&g