date.h
来自「C++程序设计教程(第二版)课件以及源代码 是初学者接触并能很好理解的参考书」· C头文件 代码 · 共 26 行
H
26 行
//=====================================
// date.h
// class Date derived from IDate
//=====================================
#include"idate.h"
#include<iostream>
//-------------------------------------
class Date : public IDate{
int year, month, day;
protected:
int ymd2i()const;
void i2ymd(int n);
static const int tians[];
bool isLeapYear()const{ return !(year%4)&&(year%100)||!(year%400); }
public:
Date(const std::string s);
Date(int n){ i2ymd(n); }
Date(int y, int m, int d):year(y),month(m),day(d){}
~Date(){}
Date& operator+(int n){ return *new Date(ymd2i()+n); }
Date& operator+=(int n){ i2ymd(ymd2i()+n); return *this; }
Date& operator++(){ return *this +=1; }
void print(std::ostream& o)const;
};//-----------------------------------
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?