Class Specification Input Range Time Time

Such as writing 128093

#include <iostream>
#include "myFunction.h"
using namespace std;

int main()
{
        Time t1;

        t1.setTime(12, 80, 93);
        cout << "t1 ";
        t1.printUniversal();

    return 0;
}

The time range specification

void Time::setTime(unsigned int h, unsigned int m, unsigned int s)
{
    hour = (h>=0 && h<24)? h : 0;//问号前 为判断,问号后 为选择 h 或 0
    minute = (m>=0 && m<60)? m : 0;
    second = (s>=0 && s<60)? s : 0;
}

Run results
Here Insert Picture Description

Published 10 original articles · won praise 0 · Views 23

Guess you like

Origin blog.csdn.net/qq_44933833/article/details/104918724