int sign=0;//用于判断用那种方式
class date
{
private:
int day,month,year;
char char_day[30];
public:
// int sign=0;
date(char *string);
date(int d ,int m,int y );
void display(void);
void set_date(char *string);
void set_date(int ,int ,int);
};
date::date(char *string="21 December 2004")
{
strcpy(char_day,string);sign=0;
}
date::date(int d=21,int m=12,int y=2004)
{ day=d;
month=m;
year=y;
sign=1;
}
void date::display (void)
{
if(sign==0)
cout<<char_day<<endl;
else
cout<<day<<"/"<<month<<"/"<<year<<endl;
}
void date::set_date (char *string)
{
strcpy(char_day,string);sign=0;
}
void date::set_date (int d,int m,int y)
{day=d;
month=m;
year=y;
sign=1;
}
void main(void)
{
date Mydate("12 JUne 2004");
Mydate.display ();
Mydate.set_date (12,12,2003);
Mydate.display ();
}