时间和日期三的参考

#include <bits/stdc++.h>
#include
#include
using namespace std;
class Time{
private:
friend class DateTime;
int hh,mm,ss;
public:
Time():hh(0),mm(0),ss(0)
{
cout<<“CREATE Time : (”<<hh<<", “<<mm<<”, “<<ss<<”)"<<endl;
}
Time(int a,int b,int c):hh(a),mm(b),ss©{}
Time &setTime(int a,int b,int c){hh=a;mm=b;ss=c;return *this;}
void showTime()
{
cout<<setw(2)<<setfill(‘0’)<<hh<<":"<<setw(2)<<setfill(‘0’)<<mm<<":"<<setw(2)<<setfill(‘0’)<<ss;
}
};

class Date{
private:
friend class DateTime;
int year,month,day;
public:
Date():year(1),month(1),day(1){
cout<<“CREATE Date : (”<<year<<", “<<month<<”, “<<day<<”)"<<endl;
}
Date(int a,int b,int c):year(a),month(b),day©{}
Date &setDate(int a,int b,int c){year=a;month=b;day=c;return *this;}
void showDate() {
cout<<setfill(‘0’)<<setw(4)<<year<<"-"<<setfill(‘0’)<<setw(2)<<month<<"-"<<setfill(‘0’)<<setw(2)<<day<<" ";
}
};

class DateTime{
private:
friend class Date;
friend class Time;
Time T;
Date D;
int year1,month1,day1,hh1,mm1,ss1;
public:
DateTime(){
cout<<“CREATE DateTime : (”<<D.year<<", “<<D.month<<”, “<<D.day<<”, “<<T.hh<<”, “<<T.mm<<”, “<<T.ss<<”)"<<endl;
}
DateTime(const Date& d,const Time& t)?(d),T(t){}
DateTime(int a,int b,int c,int d,int e,int f)?(a,b,c),T(d,e,f){}
void showDateTime(){
D.showDate(); T.showTime();
}
DateTime &setDateTime(int a,int b,int c,int d,int e,int f){
D.setDate(a,b,c);T.setTime(d,e,f);return *this;
}
};

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值