/** Copyright (c) 2013, School of Computer Science, Yantai University * All rights reserved. * file name: test. cpp * Author: Qiu xuewei * Completion Date: July 15, April 15, 2013 * version: v1.0 * input Description: none * Problem description: Reference of static functions * program output: Time class * problem analysis: * Algorithm Design: omitted */
# 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 format is-08:23:05/PM/pmvoid add_seconds (INT); // Add n seconds void add_minutes (INT ); // Add n minutes void add_hours (INT); // Add n hours static void change24 (); // change the static member is_24, convert static void changefrom0 () between 12 and 24; // change the static member from0, and switch whether the leading 0 PRIVATE: static bool is_24; // when the value is true, 24-hour format, for example,; For flase, 12 small Time, displayed as PM static bool from0; // if it is true, the leading: 23: 5 is displayed as 08: 23: 05int hour; int minute; int sec ;}; // write the initialization of static members and the definition of each member function bool time: is_24 = true; bool time: from0 = false; Time: Time (int h, int M, int S): hour (H), minute (M), SEC (s) {}; void time: show_time () {int h; H = (is_24 )? Hour: hour % 12; If (hour <10 & from0) cout <"0"; cout