C++:类与对象

来源:百度知道 编辑:UC知道 时间:2024/05/14 02:20:59
设计一个用于人事管理的“人员”类,由于考虑到通用性,这里只抽象出所有类型人员都具有的属性:编号,性别,出生日期、身份证号等。其中“出生日期”声明为一个“日期”类内嵌子对象。用成员函数实现对人员信息的录入和显示。要求包括:构造函数和析构函数、拷贝构造函数、内联成员函数、带默认形参值的成员函数、类的组合

多给些分~~~
#include<iostream.h>

class worker
{

public:

class time
{
private:
int date;
int month;
int year;
public:
time(){}
time(int d,int m,int y){date=d;month=m;year=y;}
~time(){};
const time& operator=(const time &n)
{
this->date = n.date;
this->month = n.month;
this->year = n.year;
return *this;}
inline void get_birthtime(){cout<<year<<"年 "<<month<<"月 "<<date<<"日 "<<endl;}
};

worker(){}
worker(int f, char *g ,long int id,time &b){num=f;gender=g;ID_card=id;birth=b;}
~worker(){}
worker(worker &a){num=a.num;gender=a.gender;ID_card=a.ID_card;birth=a.birth;}

void set_worker(int f, char *g ,long int id,time