forked from Dashark/hello-world
-
Notifications
You must be signed in to change notification settings - Fork 0
/
datetime-1.cpp
42 lines (40 loc) · 869 Bytes
/
datetime-1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
class DateTime {
private:
int seconds; //从1970年1月1日0时开始计算的秒数
public:
DateTime();
DateTime(int y, int m, int d, int hour, int minute, int second);
DateTime(const DateTime &dt);
~DateTime();
void showTime();
void showMoon(); //作业:将当前公历转换为农历显示出来
};
int main() {
DateTime dt, dt1(2020, 3, 27, 10, 40, 55);
DateTime dt2(dt), &dt3 = dt;
DateTime *dt4 = &dt;
dt.showTime();
dt1.showTime();
dt2.showTime();
dt3.showTime();
dt4->showTime();
return 0;
}
DateTime::DateTime()
{
}
DateTime::DateTime(int y, int m, int d, int hour, int minute, int second)
{
}
DateTime::DateTime(const DateTime &dt)
{
}
DateTime::~DateTime()
{
std::cout << " Go die, Ha~Ha~" << std::endl;
}
void DateTime::showTime()
{
printf("当前时间:%d/%d/%d %d:%d:%d\n", year, month, day, hour, minute, second);
}