Describe
Using C + + to implement date class CDate and Time Class CTime, and use multi-inheritance to implement date-time class Cdatetime on sub-basis, so that it can output sample information.
The code in the main function is given, please fill it out, and do not include the code that you have given when committing.
int main () {int y, M, D, hh, MM, Ss;while (CIN>>Y>>M>>D>>HH>>MM>>SS) {cdatetime dt (Y, M,D,HH,MM,SS);d T. Print ();((CDate) DT). Print ();((CTime) DT). Print ();} return 0;}
Input
There are several groups of input data, one row per group, and 6 positive integers per action, representing the year, month, day, hour, minute, and second of a DateTime.
Date information is guaranteed to be valid.
Output
Output date time, date, time, and so on as sample format.
Sample input
2000 3 1 12 9 9
Sample output
2000-3-1 12:9:9
2000-3-1
12:9:9
#include <iostream>using namespacestd;classcdate{protected: inty,m,d; Public: CDate (); CDate (intYintMintd): Y (y), M (m), D (d) {}voidPrint () {cout<<y<<"-"<<m<<"-"<<d<<Endl; } };classctime{protected: intHh,mm,ss; Public: CTime (); CTime (inthhintMmintss): HH (hh), mm (mm), SS (ss) {}voidPrint () {cout<":"<<mm<<":"<<ss<<Endl; }};classCdatetime: PublicCDate, Publicctime{ Public: Cdatetime (); Cdatetime (intYintMintDinthhintMmintss): CDate (Y,m,d), CTime (HH,MM,SS) {}voidPrint () {cout<<CDate::y<<"-"<<CDate::m<<"-"<<cdate::d <<" "<<CTime::hh<<":"<<CTime::mm<<":"<<CTime::ss<<Endl; }};intMain () {inty, M, D, HH, MM, SS; while(cin>>y>>m>>d>>hh>>mm>>SS) {cdatetime dt (Y,M,D,HH,MM,SS); Dt. Print (); ((CDate) DT). Print (); ((CTime) DT). Print (); } return 0;}
"TOJ 5247" C + + experiment: Time and Date classes