求写剩下的部分,思路也行
涉及一个虚类Staff(员工),包含编号、姓名和年龄保护数据成员以及相关的成员函数;由Staff派生出工程师类Engieer,包含专业和职称保护数据成员以及相关的成员函数;再由Staff派生出领导类Leader,包含职称和部门保护数据成员以及相关的成员函数;然后由Engineer和Leader类派生出主任工程师类Chairman设计一个利用文件处理方式实现对公司人员(包括工程师、领导和主任工程师)进行管理,具有增加数据、更新数据、查询数据、删除数据以及重组数据文件的功能。
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
class staff
{
protected:
int num,age;
string name;
public:
virtual void input()=0;
virtual void show()=0;
virtual void Read(fstream &f)const=0;
virtual void Write(fstream &f)const=0;
};
class engieer:virtual public staff
{
protected:
string major;//专业
string workname;//职称
public:
fstream out;
out.open("staff.dat");
void input()
{
cout<<"编号"<<endl;
cin>>num;
cout<<"名字"<<endl;
cin>>name;
cout<<"专业"<<endl;
cin>>major;
cout<<"职称"<<endl;
cin>>workname;
}
void show()
{
cout<<"名字"<<name<<endl;
cout<<"编号"<<num<<endl;
cout<<"年龄"<<age<<endl;
cout<<"专业"<<major<<endl;
cout<<"职称"<<workname<<endl;
}
void Read(fstream &f)const
{
f.read((char*)this,sizeof(engineer));
}
void Write(fstream &f)const
{
f.write((char*)this,sizeof(engineer));
}
out.close();
};
class leader:virtual public staff
{
protected:
string job;//职务
string dep;//部门
public:
out.open("staff.dat");
void input()
{
cout<<"编号"<<endl;
cin>>num;
cout<<"名字"<<endl;
cin>>name;
cout<<"部门"<<endl;
cin>>dep;
cout<<"职务"<<endl;
cin>>job;
}
void show()
{
cout<<"名字"<<name<<endl;
cout<<"编号"<<num<<endl;
cout<<"年龄"<<age<<endl;
cout<<"部门"<<dep<<endl;
cout<<"职务"<<job<<endl;
}
void Read(fstream &f)const
{
f.read((char*)this,sizeof(engineer));
}
void Write(fstream &f)const
{
f.write((char*)this,sizeof(engineer));
}
out.close();
};
class chairman:public engineer,public leader
{
public:
out.open("staff.dat");
void Input()
{
cout<<"编号:";
cin>>num;
cout<<"姓名:";
cin>>name;
cout<<"年龄:";
cin>>age;
cout<<"专业:";
cin>>major;
cout<<"职称:";
cin>>workname;
cout<<"职务:";
cin>>job;
cout<<"部门:";
cin>>dep;
}
void show()
{
cout<<"编号"<<num<<endl;
cout<<"名字"<<name<<endl;
cout<<"年龄"<<age<<endl;
cout<<"专业"<<major<<endl;
cout<<"职称"<<major<<endl;
cout<<"职务"<<job<<endl;
cout<<"部门"<<dep<<endl;
}
void Read(fstream &f)const
{
f.read((char*)this,sizeof(Chairman));
}
void Write(fstream &f)
{
f.write((char*)this,sizeof(Chairman));
}
out.close();
};
求输出,删除,增加,修改