?? mydate.cpp
字號:
#include "iostream"
#include "myDate.h"
Date::Date()
{
year = month = day = 0;
}
Date::Date(int y, int m, int d)
{
year = y;
month = m;
day = d;
}
//對‘ 〉’運算符重載
bool Date::operator>(const Date & D) const
{
if(year > D.year)
return true;
if((year == D.year) && (month > D.month))
return true;
if((year == D.year) && (month == D.month) && (day > D.day))
return true;
else
return false;
}
//對‘〈 ’運算符重載
bool Date::operator<(const Date & D) const
{
if(year < D.year)
return true;
if((year == D.year) && (month < D.month))
return true;
if((year == D.year) && (month == D.month) && (day < D.day))
return true;
else
return false;
}
//對‘ = ’運算符重載
bool Date::operator=(const Date & D) const
{
if((year == D.year) && (month == D.month) && (day == D.day))
return true;
else
return false;
}
//定義Show(), 方便輸出
void Date::Show() const
{
cout << year << " year, " << month << " month, " << day << " day ";
cout << '\n';
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -