📄 date.cpp
字号:
// Date.cpp: implementation of the Date class.
//
//////////////////////////////////////////////////////////////////////
#include <iostream.h>
#include "Date.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
int songay(int m, int y){
int sn[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
if (((y%4==0)&&(y%100!=0))||(y%400==0))
sn[2] = 29;
return sn[m];
}
Date::Date()
{
}
Date::~Date()
{
}
Date Date::operator ++()
{
if (d<songay(m,y)) d++;
else {
if (m<12)m++;
else {y++;m=1;}
d = 1;
}
return (*this);
}
Date Date::operator ++(int)
{
Date t = *this;
++(*this);
return t;
}
istream &operator >> (istream &in, Date &x){
cout<<"Nhap ngay:"; in>>x.d;
cout<<"Nhap thang:"; in>>x.m;
cout<<"Nhap nam:"; in>>x.y;
return in;
}
ostream &operator << (ostream &out,const Date &x){
out<<x.d<<"/"<<x.m<<"/"<<x.y<<endl;
return out;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -