设计某小型公司的 employee(人员)类.doc

设计某小型公司的 employee(人员)类.doc

  1. 1、本文档共6页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
设计某小型公司的 employee(人员)类

/* 1. 人员管理 设计某小型公司的 employee(人员)类 (1)类 1)employee 类: 基本信息:编号、姓名、性别、出生日期、职位等; 出生日期使用自定义的 Date(日期)类; 其中:基本信息为 private 属性,成员函数为public 属性; 多个构造函数:缺省构造函数、带参数的构造函数、带默认参数的构造函数; 可以从外部访问类成员的友员函数; 2)Date 类: 成员变量:年、月、日 成员函数:SetYear(int year)、SetMonth(int month)、SetDay(int day) GetYear()、GetMonth()、GetDay() (2)基本功能: 1)职工信息的录入; 2)职工信息的显示; 3)用对象数组保存已输入的职工对象; 4)可以修改人员的基本信息,如:姓名、职位等; 5)可以通过编号或姓名进行人员查询; (3)实验提示 1)注意带参数的构造函数和带默认参数的构造函数的声明与定义; 2)定义employee 类的成员变量时,应注意变量类型的声明; 3)在查询时,通过申明成employee 类的友元函数来访问类的成员变量; */ #include iostream #include string #define N 100 using namespace std; class Date { private: int year; int month; int day; public: void SetYear(int x) {year=x;} void SetMonth(int x) {month=x;} void SetDay(int x) {day=x;} int GetYear() {return year;}//获取年 int GetMonth() {return month;}//获取月 int GetDay() {return day;}//获取日 Date():year(2000),month(1),day(1) { } Date(int x, int y,int z) { year=x; month=y; day=z; } }; class employee { private: int no; char name[16]; char sex[8]; Date birth; char pos[32]; public: void Setname(char* n) { strcpy(name,n); } void Setpos(char* n) { strcpy(pos,n); } employee():no(0),birth(2000,1,1) { strcpy(name,Andy); strcpy(sex,male); strcpy(pos,intern); } employee operator=(employee x) { no=x.no; birth.SetYear(x.birth.GetYear()); birth.SetMonth(x.birth.GetMonth()); birth.SetDay(x.birth.GetDay()); strcpy(name,x.name); strcpy(sex,x.sex); strcpy(pos,x.pos); } employee(int n, char* str, char* y,Date day, char* p) { no = n; strcpy(name,str); strcpy(sex,y); birth=day; strcpy(pos,p); } friend string Getname(employee x) { string name; int i; for(i=0;x.name[i]!=\0;i++) name+=x.name[i]; return name; } friend int Getno(employee x) { return x.no; } friend string Getsex(employee x) { string sex; int i; for(i=0;x.sex[i]!=\0;i++) sex+=x.sex[i]; return sex; } friend Date Getbirth(employee x) { return x.birth; } friend string Getpos(employee x) {

文档评论(0)

xcs88858 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:8130065136000003

1亿VIP精品文档

相关文档