This paper describes the method of realizing the alarm clock program in C + +, the code structure is relatively simple, and the annotation is perfect. We are now sharing them for your reference.
The specific function code is as follows:
#include <iostream> #include <string> #include <ctime> using namespace std;
Time class time{Private:int hour;
int minute;
int second;
Public://Set time void set (int h,int m,int s) {hour = h;
minute = m;
Second = s;
{Next () {if (second<59) second++) ()//Time to go one second, minutes and seconds.
else if (minute<59) {second=0;
minute++;}
else if (hour<23) {minute=0;
hour++;}
else hour=0;
//Get time int getting () {return hour*10000+minute*100+second;
}
};
Clock class clock{private:time now;
Time Ring_time;
Public://on the table, set the initial time void Adjust_now (int h,int m,int s) {now.set (h,m,s);
cout<< "Now the time is:" <
Interested readers can test and run the instance code, and the lack of functionality can be improved and perfected according to the situation. Hope that this example can help you learn C + + play a certain role.