#include <iostream>
#include <fstream>
using namespace std;
class worker;
class Boss;
void header()
{
cout << "编号\t"<<"姓名\t" <<"岗位\t"<<"\t职责"<<endl;
}
class workermanager
{
public:
workermanager()
{
m_Empnum=0;
m_Emparray=NULL;
}
void show_menu()//显示功能函数
{
cout << "\t**************************" << endl;
cout << "\t***欢迎使用职工管理系统***"<< endl;
cout << "\t******0.退出管理系统******"<< endl;
cout << "\t******1.增加职工信息******"<< endl;
cout << "\t******2.显示职工信息******"<< endl;
cout << "\t******3.删除职工信息******"<< endl;
cout << "\t******4.修改职工信息******"<< endl;
cout << "\t******5.查找职工信息******"<< endl;
cout << "\t******6.按照编号排序******"<< endl;
cout << "\t******7.清空所有文档******"<< endl;
cout << "\t**************************"<< endl;
}
void exitsystem()
{
cout << "\t欢迎下次使用"<< endl;
// system("pause");
exit(0);
}
void add_emp()
{
cout << "请输入添加职工数量:";
int addnum=0;
cin >> addnum;
if(addnum>0)
{
int newsize=this->m_Empnum+addnum;
worker ** newspace=new worker*[newsize];
if(this->m_Emparray!=NULL)
{
for(int i = 0;i < m_Empnum;i++)
{
newspace[i]=this->m_Emparray[i];
}
}
for(int i = 0;i <addnum ;i++)
{
int id;
string name;
int Deptid;
cout << "请输入第"<< i+1<<"个职工编号";
cin >> id;
cout << "请输入第"<< i+1<<"个职工姓名";
cin >> name;
cout<<"请输入第"<<i+1<<"个职工岗位";
cout << "1.普通职工"<< endl;
cout << "2.经理"<< endl;
cout << "3.老板"<< endl;
cin >> Deptid;
/* worker * wr=NULL;
switch(Deptid)
{
case 1:
wr=new Employaa();
break;
case 2:
wr=new manager(id,name,2);
break;
case 3:
wr=new Boss(id,name,3);
break;
}
newspaper[this->m_Empnum+i]=wr;
delete[] this->m_Emparray[i];
m_Emparray=newspace;*/
worker *w=NULL;
w=new Boss(1,"张三",1);
}
}else
{
cout << "数量有误"<< endl;
return;
}
}
int m_Empnum;
worker** m_Emparray;
~workermanager(){};
};
class worker//员工抽象类
{
public:
virtual void showinf()=0;//显示个人信息
virtual string getDeptName()=0;//获取岗位名称
int m_id;//职工编号
string m_name;//职工姓名
int m_Deptid;//职工所在岗位编号
};
class Employaa:public worker
{
public:
Employaa(int id,string name,int Deptid)
{
m_name=name;
m_id=id;
m_Deptid=Deptid;
}
void showinf()
{
cout<<m_id<<m_name<<this->getDeptName()<<endl;
}
string getDeptName()
{
return string("员工");
}
};
class manager:public worker
{
public:
manager(int id,string name,int Deptid)
{
m_id=id;
m_name=name;
m_Deptid=Deptid;
}
void showinf()
{
cout<<m_id<<m_name<<this->getDeptName()<<endl;
}
string getDeptName()
{
return string("经理");
}
};
class Boss:public worker
{
public:
Boss(int id,string name,int Deptid)
{
m_id=id;
m_name=name;
m_Deptid=Deptid;
}
void showinf()
{
cout<<m_id<<m_name<<this->getDeptName()<<endl;
}
string getDeptName()
{
return string("老板");
}
};
int main()
{
workermanager wm;
int choice=0;
wm.show_menu();
while(1)
{
cout<<"请选择操作:";
cin >> choice;
switch(choice)
{
case 0:
{
wm.exitsystem();
break ;
}
case 1:
{
break;
};
case 2:
{
header();
break;
};
case 3:
{
break;
};
case 4:
{
break;
};
ca