【C++程序设计】P123_4-10 设计一个用于人事管理的"人员“ 类

#include <iostream>
using namespace std;

class Date{
public:
	int year,month,day;
	Date(){}
	Date(int y,int m,int d){
		year=y;month=m;day=d;
	}
};
enum SEX{MALE,FEMAL};
class Person{
private:
	int ID;
	SEX sex;
	Date birthday;
	char* IDCard;
public:
	Person(int ID, SEX sex, int y, int m, int d, char* IDCard):birthday(y,m,d){
		this->ID=ID;
		this->sex=sex;
		this->IDCard=IDCard;
	}
	Person(Person& p){
		this->ID=p.ID;
		this->sex=p.sex;
		Date tdate(p.birthday.year, p.birthday.month, p.birthday.day);
		this->birthday=tdate;
		this->IDCard=p.IDCard;
	}
	~Person(){}
	inline void setID(int ID){this->ID=ID;}
	inline void setSex(SEX sex){this->sex=sex;}
	inline void setDate(int y,int m,int d){
		birthday.year=y;
		birthday.month=m;
		birthday.day=d;
	}
	inline void setIDCard(char* IDCard){this->IDCard=IDCard;}
	void Show(){
		printf_s("ID: %d\nSex: %s\nBirthday: %d-%d-%d\nIDCard: %s\n",ID,0?"male":"femal",birthday.year,birthday.month,birthday.day,IDCard);
	}
};

int _tmain(int argc, _TCHAR* argv[]){
	Person p(69,MALE,1994,10,31,"123456789");
	p.Show();
	system("pause");
	return 0;
}

  • 12
    点赞
  • 38
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值