打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
259 对象指针

#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;

}

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
判断闰年平年
怎样输出日历,初学者必看_俊豪联盟旗下网站--天空
C语言 图书管理系统
【C 】数组讲解之二维数组
iostream_setiosflags.cpp
集合的子集和集合的全排列问题
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服