13周项目4

来源:互联网 发布:手机免费听歌软件 编辑:程序博客网 时间:2021/10/19 07:18
#include<iostream>  #include<cstdio>  using namespace std;  class Date{public:Date(int y=0,int m=0,int d=0):year(y),month(m),day(d){}   void SetDate(int y,int m,int d){   year=y;   month=m;   day=d;}   void PrintDate();private:  int year,month,day;};void Date::PrintDate(){   cout<<year<<"  "<<month<<"  "<<day<<" ";}class Time{public:Time(int h=0,int m=0,int s=0):hour(h),minute(m),second(s){}  void SetTime(int h,int m,int s);  void PrintTime();private:   int hour;   int minute;   int second;};void Time::SetTime(int h,int m,int s){     hour=h;   minute=m;   second=s;}void Time::PrintTime(){cout<<hour<<"  "<<minute<<"  "<<second<<"  ";}class TimeDate:public Date,public Time{public:TimeDate(int y,int m,int d,int h,int n,int s):Date(y,m,d),Time(h,n,s){}  void PrintTimeDate();};void TimeDate::PrintTimeDate(){PrintDate();PrintTime();}int main()  {      freopen("input.txt","r",stdin);  //只加这一句输入将被重定向到文件input.txt         int  a,b,c,d,e,f; cin>>a>>b>>c>>d>>e>>f;TimeDate num(a,b,c,d,e,f);num.PrintTimeDate();cout<<endl;    return 0;  }