#include<iostream>
using namespace std;
class Date
{
public:
void hh(int year, int month, int day)
{
_year = year;
_month = month;
_day = day;
}
void Display()
{
cout << "year" << _year << endl;
cout << "month" << _month << endl;
cout << "day" << _day << endl;
}
Date(int year, int month, int day)
{
cout << "Date:带参数的构造函数" << endl;
_year = year;
_month = month;
_day = day;
}
Date(int year )
{
cout << "Date:带缺省值构造函数" << endl;
_year =2015 ;
_month = 8;
_day = 17;
}
Date()
{
cout << "无参构造函数" << endl;
_year = 2013;
_month = 8;
_day = 17;
}
private:
int _year;
int _month;
int _day;
};
int main()
{
//Date p1(2015, 8, 17);
//p1.Display();
//Date p2(2015);
//p2.Display();
Date p3;
p3.Display();
时间: 2024-10-29 19:10:20