第1个回答 2019-04-04
#include<iostream>
using namespace std;
class Timedate{
public:
Timedate() {}
//参数自己去判断
void setDate(int yy, int mm ,int dd ) { year = yy; month= mm; day= dd;}
void setTime(int _h, int _m, int _s) { h= _h; m= _m; s= _s; }
void outPutDate(){ cout << "date:"<<year<<"-"<<month<<"-"<<day; };
void outPutTime(){ cout << "time:"<<h<<":"<<m<<":"<<s; };
private:
int year;
int month;
int day;
int h;
int m;
int s;
};
int main(int argc, char* argv)
{
Timedate td;
dt.setDate(2019,4,4);
dt.setTime(9,20,20);
td.outPutDate();
td.outPutTime()
}本回答被提问者和网友采纳