/*
*copyright (c) 2015, College of Computer Science, Yantai University
*all rights reserved.
* File name: Week fifth (timetable)
* Wangzhong
* Completion Date: 2015.4.8
* Version Number: v1.0
*
* Problem Description: Design a time class that contains static data members and member functions. A static data member is a common data for all objects in a class, in the following design, whether the clock is to be 12-hour or 24-hour, or if the number that is less than two digits is preceded by 0, is a "global" setting that is appropriate as a static data member in the class.
* Input Description: Time
* Program output: Time
#include <iostream>using namespace Std;class time{public:time (int=0,int=0,int=0); void Show_time (); According to Is_24 and FROM0, the output is suitable for form -20:23:5/8:23:5 pm/08:23:05 pm void add_seconds (int); Added n seconds void add_minutes (int); Added n minutes void add_hours (int); Added n-hour static void Change24 (); Change static member is_24, convert static void Changefrom0 () between 12 and 24 o'clock; Change static member From0, toggle whether leading 0private:static bool is_24; When True, the 24-hour system, such as 20:23:5, is flase,12-hour, and is displayed as 8:23:5 pm static bool from0; When True, the leading 0,8:23:5 is displayed as 08:23:05 int hour; int minute; int sec;};/ /write down the initialization of the static member and the definition of the member function ... bool Time::is_24=true;bool time::from0=true;int main () {Time T1 (16,24,25), T2 (8,9,7); T1.show_time (); T2.show_time (); T1.add_seconds (40); T1.show_time (); T1.add_minutes (20); T1.show_time (); T1.add_hours (4); T1.show_time (); T1.change24 (); T1.show_time (); T1.changefrom0 (); T1.show_time (); return 0;} Time::time (int h,int m,int s): Hour (h), Minute (m), SEC (s) {}void time::show_time () {int h; if (is_24) H=hour; else h=hour%12; if (from0&&h<10) cout<< "0"; cout<
Week five (timetable)