使用c++实现职工管理系统的基本功能
0-退出管理程序
1-增加职工信息
2-显示职工信息
3-删除离职职工
4-修改职工信息
5-查找职工信息
6-按照编号排序
7-清空所有文档
boss.cpp
#include"Boss.h"
//构造函数
Boss::Boss(int id, string name, int did) {
this->m_id = id;
this->m_name = name;
this->m_number = did;
}
//显示个人信息
void Boss::showinfo() {
cout << "职工编号:" << this->m_id
<< "\t职工姓名:" << this->m_name
<< "\t岗位:" << this->getdeptname()
<< "\t岗位职责:管理公司所有事务" << endl;
}
//获取岗位名称
string Boss::getdeptname() {
return string("老板");
}
boss.h
#pragma once
#include<iostream>
#include<string>
using namespace std;
#include"Worker.h"
//经理类
class Boss :public Worker {
public:
//构造函数
Boss(int id, string name, int did);
//显示个人信息
virtual void showinfo();
//获取岗位名称
virtual string getdeptname();
};
Employee.cpp
#include"Employee.h"
#include<string>
//构造函数
Employee::Employee(int id, string name, int did) {
this->m_id = id;
this->m_name = name;
this->m_number = did;
}
//显示个人信息
void Employee::showinfo()
{
cout << "职工编号:" << this->m_id
<< "\t职工姓名:" << this->m_name
<< "\t岗位:"<<this->getdeptname()
<< "\t岗位职责:完成经理交给的任务" << endl;
}
//获取岗位名称
string Employee::getdeptname() {
return string("普通员工");
}
Employee.h
//普通员工文件
#pragma once
#include<iostream>
#include<string.h>
#include"Worker.h"
using namespace std;
class Employee :public Worker {
public:
//构造函数
Employee(int id,string name,int did);
//显示个人信息
virtual void showinfo();
//获取岗位名称
virtual string getdeptname();
};
manager.h
#include"Manager.h"
//构造函数
Manager::Manager(int id, string name, int did) {
this->m_id = id;
this->m_name = name;
this->m_number = did;
}
//显示个人信息
void Manager::showinfo() {
cout << "职工编号:" << this->m_id
<< "\t职工姓名:" << this->m_name
<< "\t岗位:" << this->getdeptname()
<< "\t岗位职责:完成老板交给的任务,并且下发任务给普通员工" << endl;
}
//获取岗位名称
string Manager::getdeptname() {
return string("经理");
}
manager.h
#pragma once
#include<iostream>
using namespace std;
#include"Worker.h"
#include<string>
#include<iostream>
using namespace std;
//经理类
class Manager:public Worker {
public:
//构造函数
Manager(int id, string name, int did);
//显示个人信息
virtual void showinfo();
//获取岗位名称
virtual string getdeptname();
};
Worker.h
#pragma once
#include<iostream>
#include<string>
using namespace std;
//职工抽象类
class Worker {
public:
//显示个人信息
virtual void showinfo() = 0;
//获取岗位名称
virtual string getdeptname() = 0;
//职工编号
int m_id;
//职工姓名
string m_name;
//部门编号
int m_number;
};
workermanager.h
#include<iostream>//防止头文件重复包含
using namespace std;//包含输入输出流头文件
#include"Worker.h"
#include<fstream>
#define FILENAME "Emfile.text"
class workermanager//使用标准命名空间
{
public:
workermanager();
//展示菜单的函数
void show_menu();
//退出系统
void exitsystem();
//记录职工人数
int m_empnum;
//职工数组指针
Worker