程序出错,谁来帮下
#include<iostream>#include<fstream>
#include<string>
using namespace std;
class Staff
{
public:
int num,age;
string name;
void fp()
{
ofstream ap;
ap.open("staff.dat",ios::out);
if(!ap)
{
cout<<"打开失败";
exit(1);
}
}
};
class engieer:virtual public Staff
{
public:
string major;
string workname;
void input1()
{
fstream ap("staff.dat");
cout<<"请输入数据"<<endl;
cout<<"编号"<<endl;cin>>num;
cout<<"年龄"<<endl;cin>>age;
cout<<"名字"<<endl;cin>>name;
cout<<"专业"<<endl;cin>>major;
cout<<"职称"<<endl;cin>>workname;
ap<<num<<" "<<age<<" "<<name<<" "<<major<<" "<<workname<<" "<<endl;
ap.close();
}
void show1()
{
cout<<num<<endl;
cout<<age<<endl;
cout<<name<<endl;
cout<<major<<endl;
cout<<workname<<endl;
}
};
class leader:virtual public Staff
{
public:
string bm;//部门
string zc;//职称
void input2()
{
fstream ap("staff.dat");
cout<<"请输入数据"<<endl;
cout<<"编号"<<endl;cin>>num;
cout<<"年龄"<<endl;cin>>age;
cout<<"名字"<<endl;cin>>name;
cout<<"部门"<<endl;cin>>bm;
cout<<"职称"<<endl;cin>>zc;
ap<<num<<" "<<age<<" "<<name<<" "<<bm<<" "<<zc<<" "<<endl;
ap.close();
}
void show2()
{
cout<<num<<endl;
cout<<age<<endl;
cout<<name<<endl;
cout<<bm<<endl;
cout<<zc<<endl;
}
};
class company:public Staff
{
public:
int g;
engieer a[1000];
leader b[100];
void add();//增加
void new1();//更新
void look();//查询
void del();//删除
void look1();
void look2();
};
void company::look1()
{
int b;
cout<<"请输入编号:";
cin>>b;
if(b==a[g].num)
{
a[g].show1();
}
else
cout<<"不存在此编号";
}
void company::look2()
{
int y;
cout<<"请输入编号:";
cin>>y;
if(y==b[g].num)
{
b[g].show2();
}
else
cout<<"不存在此编号";
}
void company::add()
{
int i;int j=0;k==0;
cout<<"请选择增加项目1.工程师2.主任:"<<endl;
cin>>i;
switch(i)
{
case 1:a[k].input1();break;
case 2:b[j].input2();break;
default:cout<<"输入错误";break;
}
k++;
j++;
}
void company::look()
{
int i;
cout<<"请选择查询1.工程师2.主任:"<<endl;
cin>>i;
switch(i)
{
case 1:look1();break;
case 2:look2();break;
default:cout<<"出入错误"<<endl;
}
}
void company::new1()
{}
void company::del()
{
}
int main()
{
int w;
company c;
cout<<"请选择"<<endl;
cout<<"1.增加"<<endl;
cout<<"2.查询"<<endl;
cout<<"3.更新"<<endl;
cout<<"4.删除"<<endl;
cin>>w;
switch(w)
{
case 1:c.add();break;
case 2:c.look();break;
case 3:c.new1();break;
case 4:c.del();break;
default:cout<<"输入错误.......";break;
}
return 0;
}
输出,删除,更新,没思路了谁帮写一下,,,,