c++ 基础知识-类与对象-实践-员工管理系统(记录)1

c++ 基础知识-类与对象-实践-员工管理系统(记录)1

1.员工基类

#pragma once//防止头文件重复包含
#ifndef _WORKER_
#define _WORKER_

#include <iostream>
using namespace std;

//职工抽象类
//利用多态管理不同职工种类
//岗位职责信息描述,获取岗位名称

class Worker
{
public:
	//构造函数
	//Worker();

	//显示个人信息
	virtual void Show_Info() = 0;

	//获取职工岗位名称
	virtual string Get_Dept_Name() = 0;

public:
	int m_Id;//职工编号

	string m_Name;//职工姓名

	int m_DeptId;//职工所在部门编号

	//virtual ~Worker();
};
#endif //_WORKER_

2.员工类-普通员工

#pragma once//防止头文件重复包含
#ifndef _EMPLOYEE_
#define _EMPLOYEE_

#include <iostream>
#include <string>
#include "worker.h"
using namespace std;

//员工类 
class Employee:public Worker
{
public:
	//构造函数
	Employee(int id,string name,int dId);
	
	//显示个人信息
	virtual void Show_Info();

	//获取职工岗位名称
	virtual string Get_Dept_Name();

	//virtual ~Employee();
};


#endif //_EMPLOYEE_
#include "employee.h"

Employee::Employee(int id,string name,int dId)
{
	this->m_Id = id;
	this->m_Name = name;
	this->m_DeptId = dId;
}

void Employee::Show_Info()
{
	cout<<"职工编号: "<<this->m_Id
		<<"\t职工姓名: "<<this->m_Name
		<<"\t岗位: "<<this->Get_Dept_Name()<<endl;
}

string Employee::Get_Dept_Name()
{
	return string("员工");
}

3.员工类-经理

#pragma once//防止头文件重复包含
#ifndef _MANAGER_
#define _MANAGER_

#include <iostream>
#include <string>
#include "worker.h"
using namespace std;

//员工类 
class Manager:public Worker
{
public:
	//构造函数
	Manager(int id,string name,int dId);

	//显示个人信息
	virtual void Show_Info();

	//获取职工岗位名称
	virtual string Get_Dept_Name();

};


#endif //_MANAGER_
#include "manager.h"

Manager::Manager(int id,string name,int dId)
{
	this->m_Id = id;
	this->m_Name = name;
	this->m_DeptId = dId;
}

void Manager::Show_Info()
{
	cout<<"职工编号: "<<this->m_Id
		<<"\t职工姓名: "<<this->m_Name
		<<"\t岗位: "<<this->Get_Dept_Name()<<endl;
}

string Manager::Get_Dept_Name()
{
	return string("经理");
}

3.员工类-老板

#pragma once//防止头文件重复包含
#ifndef _BOSS_
#define _BOSS_

#include <iostream>
#include <string>
#include "worker.h"
using namespace std;

//员工类 
class Boss:public Worker
{
public:
	//构造函数
	Boss(int id,string name,int dId);

	//显示个人信息
	virtual void Show_Info();

	//获取职工岗位名称
	virtual string Get_Dept_Name();

};


#endif //_BOSS_
#include "boss.h"

Boss::Boss(int id,string name,int dId)
{
	this->m_Id = id;
	this->m_Name = name;
	this->m_DeptId = dId;
}

void Boss::Show_Info()
{
	cout<<"职工编号: "<<this->m_Id
		<<"\t职工姓名: "<<this->m_Name
		<<"\t岗位: "<<this->Get_Dept_Name()<<endl;
}

string Boss::Get_Dept_Name()
{
	return string("老板");
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值