13年题。
This commit is contained in:
26
OOP/13Exam/2.3.cpp
Normal file
26
OOP/13Exam/2.3.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
// 在给出的时间类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;
|
||||
}
|
||||
Reference in New Issue
Block a user