#include"iostream"
#include"iomanip"
using namespace std;
class Date
{
int year, month, day;
public:
void set(int x, int y, int z)
{
year = x;
month = y;
day = z;
}
bool isleapyear();
void print()
{
cout << setw(4) << year << '-' << setw(2) << '-' << month << '-' << setw(2) << day << endl;
}
};
inline bool Date::isleapyear()
{
return(year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
}
int main()
{
Date *d=new Date ;
(*d).set(2018, 5, 5);
if ((*d).isleapyear())
(*d).print();
else cout << "爷爷不是闰年" << endl;
Date *b = new Date;
b->set(2000, 12, 6);
if (b->isleapyear())
b->print();
else cout << "爷爷不是闰年" << endl;
system("pause");
return 0;
}
联系客服