设计一个用于人事管理的类People(人员)。考虑到通用性,这里只抽象出所有类型人员都具有的属性: name(姓名)、sex(性别) 、birthyear(出生年)birthmonth(出生月)

设计一个用于人事管理的类People(人员)。考虑到通用性,这里只抽象出所有类型人员都具有的属性: name(姓名)、sex(性别) 、birthyear(出生年)、birthmonth(出生月)、birthday(出生日) 、id(身份证号)、dept(所在部门)、salary(工资)等等。要求包括下列成员函数:人员信息的录入、人员信息的显示,以及修改和读取各属性信息的公有的成员函数,另外根据需要适当添加构造函数(包括默认的构造函数、带参数的构造函数和拷贝构造函数)和析构函数实现并测试这个类。

#include<iostream>
#include<string>
#include<stdlib.h>
using namespace std;
class People
{
public:
	People();
	People(string _name,char _sex,int _birthyear,int _birthmonth,int _birthday,string  _id,string _dept,float _salary);
	People(People &p);
	~People();
	void input();
	void display();

	string GetName(){ return name; }
	char GetSex(){ return sex; }
	int GetBirthyear(){ return birthyear; }
	int GetBirthmonth(){ return birthmonth; }
	int GetBirthday(){ return birthday; }
	string GetId(){ return id; }
	string Getdept(){ return dept; }
	float Getsalary(){ return salary; }

	void SetName(string _name){	name=_name;   }
	void SetSex(char _sex){	sex=_sex;   }
	void SetBirthyear(int _birthyear){	birthyear=_birthyear;   }
	void SetBirthmonth(int _birthmonth){	birthmonth=_birthmonth;   }
	void SetBirthday(int _birthday){	birthday=_birthday;   }
	void SetId(string _id){	id=_id;   }
	void SetDept(string _dept){	dept=_dept;   }
	void SetSalary(float _salary){	salary=_salary;   }
private:
	string name;
	char sex;
	int birthyear;
	int birthmonth;
	int birthday;
	string id;
	string dept;
	float salary;
};
People::People()
{
	name="";
	sex=' ';
	birthyear=0;
	birthmonth=0;
	birthday=0;
	id="XXXXXXXXXXXXXXXXX";
	dept="";
	salary=0.0;
}
People::People(string _name,char _sex,int _birthyear,int _birthmonth,int _birthday,string _id,string _dept,float _salary)
{
	name=_name;
	sex=_sex;
	birthyear=_birthyear;
	birthmonth=_birthmonth;
	birthday=_birthday;
	id=_id;
	dept=_dept;
	salary=_salary;
}
People::People(People &p)
{
	name=p.name;
	sex=p.sex;
	birthyear=p.birthyear;
	birthmonth=p.birthmonth;
	birthday=p.birthday;
	id=p.id;
	dept=p.dept;
	salary=p.salary;
}
People::~People()
{
	cout<<"People类析构函数被调用"<<endl;
}
void People::input()
{
	cout<<"请输入人员信息:"<<endl;
	cout<<"\t姓名:";
	cin>>name;
	cout<<"\t性别:";
	cin>>sex;
	cout<<"\t出生日期(格式:年 月 日):";
	cin>>birthyear;
	cin>>birthmonth;
	cin>>birthday;
	cout<<"\t身份证号码:";
	cin>>id;
	cout<<"\t所在部门:";
	cin>>dept;
	cout<<"\t工资:";
	cin>>salary;
}
void People::display()
{
	cout<<"人员信息如下:"<<endl;
	cout<<"\t姓名:"<<name<<endl;
	cout<<"\t性别:"<<sex<<endl;
	cout<<"\t出生日期:"<<birthyear<<"/"<<birthmonth<<"/"<<birthday<<endl;
	cout<<"\t身份证号码:"<<id<<endl;
	cout<<"\t所在部门:"<<dept<<endl;
	cout<<"\t工资:"<<salary<<endl<<endl;
}

int main()
{
	People p1;
	p1.input();
	p1.display();
	People p2=p1;
	p2.display();
	
	People p3("Jerry",'F',2005,10,10,"420101200510101234","研发部",8000);
	p3.display();

	char name[15];
	int year,month,day;
	cout<<"修改姓名-请输入新的姓名:";
	cin>>name;
	p3.SetName(name);
	cout<<"修改后的新姓名是:"<<p3.GetName()<<endl;
	cout<<"修改出生年月日-请输入新的出生年月日:";
	cin>>year>>month>>day;
	p3.SetBirthyear(year);
	p3.SetBirthmonth(month); 
	p3.SetBirthday(day); 
	cout<<"修改后的新出生年月日是:"<<p3.GetBirthyear()<<"-"<<p3.GetBirthmonth()<<"-"<<p3.GetBirthday()<<endl<<endl;
	
	system("pause");
	return 0;

  • 6
    点赞
  • 40
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
人事管理是企业管理中的重要环节之一。针对这一问题,可以设计一个人事管理系统中的people。在人事管理系统中,人员信息是极其重要的,在系统中需要一个人员信息管理模块,而人员信息的抽象层级、信息存储等方面都需要一个来统一管理和处理。 在这个中,应该考虑到所有人员普遍具备的信息,比如姓名、身份证号、性别、年龄、手机号码、E-mail、地址等,这些信息可以抽象成为people中的属性。同时,我们也可以将职务等信息也加入到people中,便于人事管理员对员工的管理。 除此之外,在设计的时候,还需要考虑到面向对象编程的特点。比如,需要为people增加构造函数、析构函数、拷贝函数、运算符重载等方法。这样,可以使对象更加灵活,便于人事管理员操作和管理。 另外,为了进一步提高人事管理系统的效率,为people增加一些重要的方法也是很有必要的。比如,可以增加员工信息的录入、查询、修改、删除等方法,用于人事管理员对员工信息的管理。此外,也可以增加一些统计、分析方面的方法,便于管理者更好地了解企业的组织架构、福利水平、人力成本等信息。 通过上述的设计,可以使people人事管理系统中具有更好的通用性和适用性,为企业的人力资源管理提供了更加全面和便捷的解决方案。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值