Static functions, used by static data members

Source: Internet
Author: User
/** 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 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.