date2.cpp

来自「it is a usefull thing」· C++ 代码 · 共 26 行

CPP
26
字号
//==================================
// Date class
//==================================
#include<iostream>
#include<iomanip>
using namespace std;
//----------------------------------
class Date{
  int year, month, day;
public:
  void set(int y,int m,int d){      // 默认内联
    year=y; month=m; day=d;
  }//------------------------------
  bool isLeapYear();
  void print();
};//-------------------------------
inline bool Date::isLeapYear(){    // 显式内联
  return (year%4==0 && year%100!=0)||(year%400==0);
}//--------------------------------
void Date::print(){
  cout<<setfill('0');
  cout<<setw(4)<<year<<'-'<<setw(2)<<month<<'-'<<setw(2)<<day<<'\n';
  cout<<setfill(' ');
}//--------------------------------

 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?