作业题:现在由你自己设计一个C++的类,Date类,用来表示年月日的一个时间,类中有year、month、day三个私有成员,除此之外,有Set的成员函数,用来设置时间,还有一个print输出时间的成员函数
根据程序输入,调用Set和print函数完成要求
输入:一个要设定的时间 格式为:2020-10-10
输出:输出重置后的时间:2020:10:10
大佬的题解:
#include<bits/stdc++.h>
using namespace std;
class Date
{
private:
int year;
int month;
int day;
public:
int set()
{
cin>>year>>month>>day;
return 0;
}
int display()
{
cout<<year<<":"<<abs(month)<<":"<<abs(day)<<endl;
}
};
int main()
{
class Date date;
date.set();
date.display();
return 0;
}
问题:最后的主函数中的三个“date”分别是什么意思?