c++程序纠错

来源:百度知道 编辑:UC知道 时间:2024/05/09 10:57:56
#include<iostream.h>
class CDate
{public:
CDate(int Day,int Month,int Year)
{day=Day;
month=Month;
year=Year;
}
process(int ADD_DAYS);
printdate();
~CDate(){}
private:
int day,month,year;
};

class CDate::process(int ADD_DAYS)
{ bool loop=(year%400||(year%4=0&&year%100!=0));
date+=ADD_DAYS;
if((month==1||month==3||month==5||month==7||month==8||month==10||month==12)&&date>31)
{month++;
date-=31;
}
else
if((month==4||month==6||month==9||month==11)&&day>30)
{month++;
date-=30;
}
if(loop&&month==2&&day>29)
{month++;
date-=28;
}
}
class CDate::printdate()
{
cout<<day<<"\"<<month<<"\"<<year<<endl;
}
void main()
{CDate date(12,11,2006);
date.process(4);
dat

//帮你改好了VC下调试过了,真是佩服你错了这么多劝你还是先把C++基础搞好
#include<iostream.h>
class CDate
{
public:
CDate(int Day,int Month,int Year)
{
day=Day;
month=Month;
year=Year;
}
void process(int ADD_DAYS);
void printdate();
~CDate(){}
private:
int day,month,year;
};

void CDate::process(int ADD_DAYS)
{
int date=0;
bool loop=(year%400||(year%4==0&&year%100!=0));
date+=ADD_DAYS;
if((month==1||month==3||month==5||month==7||month==8||month==10||month==12)&&date>31)
{
month++;
date-=31;
}
else
if((month==4||month==6||month==9||month==11)&&day>30)
{
month++;
date-=30;
}
if(loop&&month==2&&day>29)
{
month++;
date-=28;
}
}
void CDate::printdate ()
{
cout<<day<<"/"<<month<<"/"<<year<<endl;

}

void main()