Files
2023-06-02 00:03:58 +08:00

26 lines
509 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 在给出的时间类Time中增加show_time函数以时秒的格式显示时间。
#include <iostream>
using namespace std;
class Time {
public:
Time(int h, int m, int s) {
hour = h, minute = m, sec = s;
}
// ______________________
// {_______________________}
void show_time() {
cout << hour << ":" << minute << ":" << sec << endl;
}
private:
int hour, minute, sec;
};
int main() {
Time T(5, 0, 0);
T.show_time();
return 0;
}