june 14

Thank you for your applying for employment with our company. Your application is now being processed. If you have any questions, please contact us.

 

Any questions you have should be directed to your recruiter.

转载于:https://www.cnblogs.com/jeanschen/p/3787903.html

好的,以下是代码示例: ```c++ #include <iostream> #include <string> #include <ctime> using namespace std; //基类Date class Date { protected: time_t now; struct tm *tm_now; public: Date() { now = time(0); tm_now = localtime(&now); } virtual void print() = 0; //虚函数print }; //派生类ShortE class ShortE : public Date { public: void print() { cout << tm_now->tm_mday << "-" << tm_now->tm_mon + 1 << "-" << tm_now->tm_year + 1900 << endl; } }; //派生类MediumDate class MediumDate : public Date { public: void print() { string month; switch (tm_now->tm_mon) { case 0: month = "Jan."; break; case 1: month = "Feb."; break; case 2: month = "Mar."; break; case 3: month = "Apr."; break; case 4: month = "May."; break; case 5: month = "Jun."; break; case 6: month = "Jul."; break; case 7: month = "Aug."; break; case 8: month = "Sep."; break; case 9: month = "Oct."; break; case 10: month = "Nov."; break; case 11: month = "Dec."; break; } cout << month << tm_now->tm_mday << "," << tm_now->tm_year + 1900 << endl; } }; //派生类LongDate class LongDate : public Date { public: void print() { string month; switch (tm_now->tm_mon) { case 0: month = "January"; break; case 1: month = "February"; break; case 2: month = "March"; break; case 3: month = "April"; break; case 4: month = "May"; break; case 5: month = "June"; break; case 6: month = "July"; break; case 7: month = "August"; break; case 8: month = "September"; break; case 9: month = "October"; break; case 10: month = "November"; break; case 11: month = "December"; break; } cout << month << " " << tm_now->tm_mday << ", " << tm_now->tm_year + 1900 << endl; } }; int main() { Date *d1, *d2, *d3; //定义基类指针 ShortE s; d1 = &s; d1->print(); //调用ShortE的print函数 MediumDate m; d2 = &m; d2->print(); //调用MediumDate的print函数 LongDate l; d3 = &l; d3->print(); //调用LongDate的print函数 return 0; } ``` 输出结果如下: ``` 14-6-2021 Jun.14,2021 June 14, 2021 ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值