Objective: To Learn Functions
Computer content: Find the added time
/*. * Copyright and version Declaration of the program. * copyright (c) 2013, a student from the computer College of Yantai University. * All rightsreserved .. * file name: text. CPP. * Author: Liu Yujin. * completion date: January 1, March 15, 2013. * version: V1.0. * input Description: Enter the current time. * Problem description: calculate the time in a few seconds. * output: the time after the increase of the output time */# include <iostream> using namespace STD; class time {public: void set_time (); void show_time (); inline void add_a_sec (); inline void add_a_minute (); inline void add_an_hour (); void add_seconds (INT); void add_minut ES (INT); void add_hours (INT); Private: bool is_time (INT, Int, INT); int hour; int minute; int sec;}; void time :: set_time () {char C1, C2; cout <"Enter the time (Format: hh: mm: SS)"; while (1) {CIN> hour> C1> minute> c2> sec; If (C1! = ':' | C2! = ':') The cout <"format is incorrect. Enter" <Endl; else if (! Is_time (hour, minute, Sec) cout <"invalid time. Enter" <Endl; elsebreak ;}} void time: show_time () {cout
Running result:
Experience: As a matter of fact, with the previous foundation, you can refer to the research and take a long time to find that the functions are almost the same, but there are differences between hours and minutes ,,,,,