2 Star 2 Fork 0

Alkaid#3529/Staff management system

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
head.h 1.94 KB
一键复制 编辑 原始数据 按行查看 历史
#pragma once
#include<iostream>
#include<string>
#include<vector>
using namespace std;
class worker
{
public:
//对外提供获取与更改私有属性的接口
void set_name(string name);
string get_name();
void set_id(string id);
string get_id();
void set_post(string post);
string get_post();
//纯虚析构,释放子类中开辟在堆区的数据
virtual ~worker() = 0;
protected:
string m_name;
string m_id;
string m_post;
};
class staff :public worker
{
public:
//有参构造,添加默认参数以兼容无参构造
//添加 explicit 关键字,杜绝隐式转换
explicit staff(string name = " ", string id = "000000", string post = "Employee", int salary = 500);
//拷贝构造,即便不使用也必须重写,解决潜在问题
explicit staff(staff& s);
//重写析构函数,正确释放开辟在堆区的数据
~staff();
//对外提供接口获取和修改薪水值
void set_salary(int salary);
int get_salary();
//运算符重载
//左移运算符重载,直接输出工作者的姓名、编号、职位及其薪水
friend ostream& operator<<(ostream& cout, staff& s);
//右移运算符重载,简化后期读入职工信息的代码
friend istream& operator>>(istream& cin, staff& s);
//赋值运算符重载,方便类之间相互赋值
staff& operator=(staff& s);
//关系运算符重载,用于后序排序
bool operator<(staff& s);
private:
//设置整形指针,指向开辟在堆区的整型变量
int* m_salary;
};
// 菜单函数,显示系统菜单,供用户选择,并根据用户选择的功能进入对应的函数
void menu(vector<staff*>& s);
// 根据指定条件定位对应元素所在位置
int Locate_staff(vector<staff*>& s, string clue);
// key == 1 新增职工
void Add_staff(vector<staff*>& s);
// key == 2 显示职工
void Display_staff(vector<staff*>& s);
// key == 3 查找并显示职工信息
void Find_staff(vector<staff*>& s);
// key == 4 修改职工信息
void Revise_staff(vector<staff*>& s);
// key == 5 删除职工信息
void Remove_staff(vector<staff*>& s);
// key == 6 排序职工信息
void Sort_staff(vector<staff*>& s);
// key == 7 清空职工
void Empty_staff(vector<staff*>& s);
// 交换指定位置的两个元素
void swap(vector<staff*>& s, int index1, int index2);
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/alkaid3529/staff-management-system.git
git@gitee.com:alkaid3529/staff-management-system.git
alkaid3529
staff-management-system
Staff management system
master

搜索帮助