📄 date.cpp
字号:
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include "date.h"
using namespace std;
date::date ()
{
day = 0;
month = 0;
year = 0;
}
date::date (int day, int month, int year)
{
this->day = day;
this->month = month;
this->year = year;
}
int date::compareTo (date another_date)
{
if(this->year == another_date.year)
{
if(this->month == another_date.month)
{
if(this->day == another_date.day)
{
return 0;
}
else if(this->day < another_date.day)
{
return -1;
}
else
{
return 1;
}
}
else if(this->month < another_date.month)
{
return -1;
}
else
{
return 1;
}
}
else if(this->year < another_date.year)
{
return -1;
}
else
{
return 1;
}
}
ostream &operator<< (ostream &stream, date d)
{
return stream << d.month<<"/"<<d.day<<"/"<<d.year;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -