扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
#include #include #include typedef char string80[80]; class Date { public: Date() {} Date(int y, int m, int d) { SetDate(y, m, d); } void SetDate(int y, int m, int d) { Year = y; Month = m; Day = d; } void GetStringDate(string80 &Date) { sprintf(Date, "%d/%d/%d", Year, Month, Day); } protected: int Year, Month, Day; }; class Time { public: Time() {} Time(int h, int m, int s) { SetTime(h, m, s); } void SetTime(int h, int m, int s) { Hours = h; Minutes = m; Seconds = s; } void GetStringTime(string80 &Time) { sprintf(Time, "%d:%d:%d", Hours, Minutes, Seconds); } protected: int Hours, Minutes, Seconds; }; class TimeDate:public Date, public Time { public: TimeDate():Date() {} TimeDate(int y, int mo, int d, int h, int mi, int s):Date(y, mo, d), Time(h, mi, s) {} void GetStringDT(string80 &DTstr) { sprintf(DTstr, "%d/%d/%d;%d:%d:%d", Year, Month, Day, Hours, Minutes, Seconds); } }; void main() { TimeDate date1, date2(1998, 8, 12, 12, 45, 10); string80 DemoStr; date1.SetDate(1998, 8, 7); date1.SetTime(10, 30, 45); date1.GetStringDT(DemoStr); cout<<"The date1 date and time is:"< cout<<"The date1 date is:"< cout<<"The date1 time is:"< cout<<"The date2 date and time is:"< |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者