date.h

来自「标准C++编写的小小CRM软件,无任何平台依赖.采用标准XML作为数据库.只需重」· C头文件 代码 · 共 48 行

H
48
字号
// 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 + =
减小字号Ctrl + -
显示快捷键?