#include
#include
using namespace std;
class employee
{
public:
virtual void display()=0;
protected:
int num;
string name;
string sex;
float income;
int birthday;
int workday;
int age;
};
class teacher:public employee
{
public:
void getdata()
{
cout<<"请输入编号:"<
cout<<"请输入姓名:"<
cout<<"请输入姓别:"<
cout<<"请输入薪水:"<
cout<<"请输入生日:"<
cout<<"请输入工作年龄:"<
age=workday-birthday;
}
void display()
{
cout<<"编号:"<
int getage()
{
age=workday-birthday;
return age;
}
int getnum()
{
return num;
}
string getname()
{
return name;
}
};
class worker:public employee
{
public:
void getdata()
{
cout<<"请输入编号:"<
cout<<"请输入姓名:"<
cout<<"请输入姓别:"<
cout<<"请输入薪水:"<
cout<<"请输入生日:"<
cout<<"请输入工作年龄:"<
}
void display()
{
cout<<"编号:"<
int getage()
{
age=workday-birthday;
return age;
}
int getnum()
{
return num;
}
string getname()
{
return name;
}
};
void menu(int &choice)
{
cout<<"\t\t\t 职工信息管理系统"<
cin>>choice;
}
int main()
{
int choice=0;
int indx1=0,indx2=0;
bool flag=false;
teacher t[50];
worker w[50];
while (1)
{
int i=0;
int average=0;
int temp;
string tname;
menu(choice);
switch (choice)
{
case 1:
t[indx1++].getdata();
break;
case 2:
w[indx2++].getdata();
break;
case 3:
cout<<"显示所有教师信息:"<
{
t[i].display();
}
cout<<"显示所有工人信息:"<
{
w[i].display();
}
break;
case 4:
cout<<"教师平均年龄:"<
{
average+=t[i].getage();
}
cout<
case 5:
cout<<"工人平均年龄:"<
{
average+=w[i].getage();
}
cout<
case 6:
cout<<"请输入要删除教师的编号"<
for (i=0;i!=indx1;++i)
{
if (temp==t[i].getnum())
{
do
{
t[i]=t[i+1];
++i;
} while (i!=indx1);
cout<<"已删除"<
break;
}
}
break;
case 7:
cout<<"请输入要删除工人的编号"<
for (i=0;i!=indx2;++i)
{
if (temp==w[i].getnum())
{
do
{
w[i]=w[i+1];
++i;
} while (i!=indx2);
cout<<"已删除"<
break;
}
}
break;
case 8:
cout<<"请输入姓名:"<
for (i=0;i!=indx1;++i)
{
if (tname==t[i].getname())
{
cout<<"这位是教师"<
}
}
for (i=0;i!=indx2;++i)
{
if (tname==w[i].getname())
{
cout<<"这位是工人"<
}
}
break;
case 0:
flag=true;
break;
}
if (flag)
{
break;
}
}
return 0;
}