- Visual C++源码
- Visual Basic源码
- C++ Builder源码
- Java源码
- Delphi源码
- C/C++源码
- PHP源码
- Perl源码
- Python源码
- Asm源码
- Pascal源码
- Borland C++源码
- Others源码
- SQL源码
- VBScript源码
- JavaScript源码
- ASP/ASPX源码
- C#源码
- Flash/ActionScript源码
- matlab源码
- PowerBuilder源码
- LabView源码
- Flex源码
- MathCAD源码
- VBA源码
- IDL源码
- Lisp/Scheme源码
- VHDL源码
- Objective-C源码
- Fortran源码
- tcl/tk源码
- QT源码
date.cpp
资源名称:c.rar [点击查看]
上传用户:puke2000
上传日期:2022-07-25
资源大小:912k
文件大小:1k
源码类别:
C#编程
开发平台:
Visual C++
- //=====================================
- // date.cpp
- //=====================================
- #include"date.h"
- #include<exception>
- using namespace std;
- //-------------------------------------
- void Date::init(int y, int m, int d)throw(out_of_range){
- if(y>5000 || y<1 || m<1 || m>12 || d<1 || d>31) throw out_of_range("rangeError");
- year=y, month=m, day=d;
- }//------------------------------------
- Date::Date(const string& s)throw(out_of_range){
- int y = atoi(s.substr(0,4).c_str());
- int m = atoi(s.substr(5,2).c_str());
- int d = atoi(s.substr(8,2).c_str());
- init(y,m,d);
- }//------------------------------------
- Date::Date(int y, int m, int d)throw(out_of_range){ init(y,m,d); }
- //-------------------------------------
- bool Date::isLeapYear()const{
- return (year % 4==0 && year % 100 )|| year % 400==0;
- }//------------------------------------