#include "Class.h"
#include <stdio.h>
struct DateInfo
{
int year;
int month;
int day;
DateInfo()
{
year = 2015;
month = 04;
day = 02;
}
DateInfo(int year, int month, int day)
{
this->year = year;
this->month = month;
this->day = day;
}
void SetDay(int day)
{
this->day = day;
}
int GetDay()
{
return this->day;
}
void SetYear(int year)
{
this->year = year;
}
int GetYear()
{
return this->year;
}
void SetMonth(int month)
{
this->month = month;
}
int GetMonth()
{
return this->month;
}
};
struct TimeInfo:DateInfo
{
int hr;
int min;
int sec;
TimeInfo ()//无参初始化
{
hr = 00;
min = 00;
sec = 00;
}
TimeInfo(int hr,int min,int sec)
{
this->hr = hr;
this->min = min;
this->sec = sec;
}
void SetTime(int hr, int min, int sec)
{
this->hr = hr;
this->min = min;
this->sec = sec;
}
int GetHr()
{
return this->hr;
}
int Getmin()
{
return this->min;
}
int GetSec()
{
return this->sec;
}
};
void Test()
{
TimeInfo time(16,14,55);
TimeInfo* pt = &time;
pt->year;
pt->month;
pt->day;
pt->hr;
pt->min;
pt->sec;
DateInfo* pd = &time;
pd->year;
pd->month;
pd->day;
//printf("%d\n",);
}
int main(void)
{
Test();
return 0;
}
复习笔记-构造-继承
最新推荐文章于 2024-09-16 19:58:57 发布