Write another application with multiple inheritance types today. The time and date classes are derived from the time and date classes.
Program code
# Include <iostream> using namespace STD; Class date // Date class {public: // constructor date (INT y = 0, int m = 0, int D = 0 ); // set the date void setdate (INT y, int M, int D); // print the date void printdate () {cout <year <"year" <month <"month" <day <"day" <Endl;} protected: int year; // year int month; // month int day; // day}; // Constructor (use the initialization table to initialize data members) Date: Date (INT y, int m, int D): Year (Y), month (M), Day (d) {}// set the date void Date: setdate (INT y, int M, int D) {year = y; month = m; Day = D;} class time // time class {public: // constructor time (INT h = 0, int m = 0, int S = 0); // set the time void settime (int h, int M, int S); // print the time void printtime (); protected: int hour; // int minute; // int second; // second}; // constructor time: Time (int h, int M, int S ): hour (H), minute (M), second (s) {}// set the time void time: settime (int h, int M, int s) {hour = h; minute = m; second = s;} // print time void time: printtime () {cout
Execution result:
The time and date classes are derived from the time and date classes.