c++求助大神,我这个代码编译通过了,但是运行的时候又说源文件未编译,其
#include
#include
using namespace std;
class cDate_t
{
public:
cDate_t();
cDate_t(int y,int m,int d):year(y),month(m),day(d){} //构造函数
cDate_t operator+(int days) //实现对符号+的重载
{
cDate_t d2;
d2.day=this->day+days; //天数相加
d2.month=this->month; //月份暂且不变
d2.year=this->year; //年份暂且不变
}
cDate_t operator-(int days) //实现对符号-的重载
{
cDate_t d2;
d2.day=abs(this->day-days);
d2.month=this->month;
d2.year=this->year;
}
int IsLeapYear(int y) //判断这一年是不是闰年
//判断方法:一年能被4整除不能被100整出,能被400整除
{
return(y%100!=0&&y%4==0)||(y%400==0);
}
void fd() //找到相加或相减之后的日期是什么时候
{
cDate_t d0;
if(IsLeapYear(d0.year)) //如果是闰年的话
{
int d[]={31,29,31,30,31,30,31,31,30,31,30,31}; //2月份是29天
while(d0.day>d[d0.month-1]) //如果天数大于当月的天数
{
d0.day-=d[d0.month-1]; //则天数要进行做差
d0.month++; //月份增加
if(d0.month |
免责声明:本内容仅代表回答者见解不代表本站观点,请谨慎对待。
版权声明:作者保留权利,不代表本站立场。
|
|
|
|
|
|
|