头一次写C++,大家帮我看一下,为什么会有错
# include<iostream.h># include<stdlib.h>
# include<time.h>
class date{
public:
void trayy()
{days[0]=31,days[1]=28,days[2]=31,days[3]=30,days[4]=31,days[5]=30,days[6]=31,
days[7]=31,days[8]=30,days[9]=31,days[10]=30,days[11]=31;
}
void one(int a,int b,int c)
{year=a,month=b,day=c;}
void now()
{time_t nowtime;
struct tm *p;
time(&nowtime);
p=localtime(&nowtime);
year=1900+p->tm_year,month=1+p->tm_mon,day=p->tm_mday;
}
void output()
{
if((year%4==0)&&(year%100!=0)||(year%400==0))
days[1]++;
while(1)
{if(getch=='+') //为什么在这里会有错?提示error C2065: 'getch' : undeclared identifier
{day=day+1;
if(day>days[month-1])
month=month+1,day=1;
if(month>12)
year=year+1,month=1,day=1;
cout<<year<<month<<day<<endl;
}
if(getch=='0')//而这里同样有getch却没错?
exit(0);
}
}
private:
int year,month,day;
int days[12];
};
void main()
{
int a,b,c;
date op;
cout<<"need input data? yes press 1 no press 2"<<endl;
cin>>a;
if(a==1)
{ op.trayy();
cin>>a>>b>>c;
op.one(a,b,c);
op.output();
}
if(a==2)
{ op.trayy();
op.now();
op.output();
}
}
一个日期的C++,大家帮忙看一下,我实在不知道为什么会这样