/* (C) 2012, all rights reserved, School of Computer Science, Yantai University. file Name: test. CPP Author: Liu Yuanlong completion date: May 26, 2013 version No.: V1.0 input Description: No Problem description: Program Output: Problem Analysis: Algorithm DESIGN: */# include <iostream> using namespace STD; Class Date {protected: int y, M, D; public: Date (INT y = 0, int m = 0, int D = 0): Y (Y), m (M), D (d) {} void printdate () ;}; void Date: printdate () {cout <"Date:" <Endl; cout <Y <"year" <m <"month" <D <"day "; cout <Endl;} class time {protected: int H, F, S; public: void printtime (); time (INT h = 0, int f = 0, int S = 0): H (H), F (F), S (s) {}}; void time: printtime () {cout <"Time: "<Endl; cout <H <" Hour "<F <" Minute "<S <" second "; cout <Endl;} class datetime: public date, public time {public: datetime (INT y = 0, int m = 0, int D = 0, int h = 0, int f = 0, int S = 0): Date (Y, M, d), time (H, F, S) {} void set () ;}; void datetime: Set () {printdate (); printtime () ;}int main () {datetime D (,); D. set (); Return 0 ;}
Running result: