一、问题描述
- 公司今天招聘了10名员工(A B C D E F G H I J),10名员工进入公司之后,需要指派员工在哪个部门工作
- 员工信息:姓名、工资
- 公司部门:策划、美术、研发
- 随机给10名员工分配部门和工资、工资范围在10k-15k之间
- 通过multimap进行信息的插入<key(部门编号),value(员工)>
- 分部门显示员工信息
二、代码实现
#include <iostream>
#include <multimap>
#include <string>
#include <cstdlib>//随机数
using namespace std;
//员工类
class Staff {
private :
string name;
unsigned int wages;
public :
Staff(string n, int w) : name(n), wages(w) {}
void setName(string n) { this->name = n; }
string getName() { return this->name; }
void setWages(int w) { this->wages = w; }
int getWages() { return this->wages; }
};
//重载<<运算符
ostream& operator<<(ostream& cout, Staff staff) {
cout << staff.getName() << "的工资是" << staff.getWages() << "元";
return cout;