📄 date.h
字号:
// Date.h: interface for the Date class.
//
//////////////////////////////////////////////////////////////////////
#pragma once
#ifndef _DATA_
#define _DATA_
#include <iostream>
#include <strstream>
using namespace std;
class Date
{
friend istream& operator >> ( istream& is, Date& d);
friend ostream& operator << ( ostream& os, Date& d);
friend class DateTime;
public:
Date();
Date( unsigned Year, unsigned Month, unsigned Day );
Date( const Date& date );
Date( char* date );
virtual ~Date();
public:
unsigned getYear() { return year; }
unsigned getMonth() { return month; }
unsigned getDay() { return day; }
void setDate( unsigned y, unsigned m, unsigned d ); // setting date
bool leapYear( int y ) const; // is this a leap year?
bool endOfMonth( int d ) const; // is this end of month
Date &operator ++ (); // preincrement operator
Date operator ++ ( int i ); // postincrement operator
const Date &operator += ( unsigned d ); // add days, modify object
bool operator == (const Date& date); // check the first Date equal to the other.
bool operator > (const Date& date); // check the first Date later than the follow
bool operator < (const Date& date); // check the first Date earlier than the follow
private:
void increment(); // increment a day
unsigned year:18;
unsigned month:5;
unsigned day:9;
static const unsigned days[]; // array of days per month
};
istream& operator>> ( istream& is, Date& d);
ostream& operator<< ( ostream& os, Date& d);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -