跪求一个c++程序,设计满足如下要求:

2024年11月27日 18:30
有1个网友回答
网友(1):

QQ多少啊? #include
#include
using namespace std;
class CTime
{
private:
int m_hour;
int m_minute;
int m_second;
public:
CTime(int h=0,int m=0,int s=0)
{m_hour=h;m_minute=m;m_second=s;}
int setTime()
{
int hour, minute, second;
cout<<"输入xxxx:xx"< cin>>hour>>minute>>second;
m_hour=hour;
m_minute=minute;
m_second=second;
}
void show()
{
cout< }
};
class CDate:public CTime
{
public:
int m_year;
int m_month;
int m_day;
public:
CDate(int month=1, int day=1, int year=1900)
{
if(month>12)
{int t=month;month=year;year=t;}
m_year=year;
m_month=month;
m_day=day;
}
int setDate()
{
int month,day,year;
cout<<"输入日期\n";
cin>>month>>day>>year;
if(month>12)
{int t=month;month=year;year=t;}
m_year=year;
m_month=month;
m_day=day;
bool flag;
cout<<"是否输入时间?1/0";
cin>>flag;
if(flag)
CTime::setTime();
}
void show()
{
cout<<"日期:"< CTime::show();
}
};
int main()
{
CDate shengri,b(1990,8,7),c(9,6,1992);
shengri.show();
b.show();
c.show();
cout<<"输入生日";
shengri.setDate();
shengri.show();
}