C++练习:时间类
#include <iostream>
#include <time.h>
using namespace std;
class Date {
private:
int year, month, day,hour;
void setsystemdate();
public:
void init(int,int,int,int);
void print_ymd();
void print_mdy();
int get_year(){
return year;};
int get_month(){
return month;};
int get_day(){
return day;}
int get_hour(){
return hour;};
bool Isleapyear();
};
void Date::setsystemdate(){
tm *gm;
time_t t=time(NULL);
gm=localtime(&t);
year=1900+gm->tm_hour;
month=gm->tm_mon+1;
day=gm->tm_mday;
hour=gm->tm_hour;
}
void Date::init(int yy,int mm,int dd,int hh){