求教c++问题,,,帮我看看这个程序,哪里有问题了啊,好多的错误不能运行,谢谢大家
#include<iostream>#include<string.h>
#include<fstream>
using namespace std;
class Employee
{
protected:
char name[20];
int num;
int rank;
float wages;
static int count;
public:
Employee();
void print();
friend class Head;
};
class Mansger:virtual public Employee{
public:
Mansger():Employee();
void print();
void save();
friend class Head;
}
class Salemansger:virtual public Employee
{
protected:
int sum;
public:
Salemansger():
Employee();
void print();
void save();
friend class Head;
};
class Technology:virtual public Employee
{
protected:
int time;
public:
Technology():Employee();
void print();
void save();
friend class Head;};
class Salesman:virtual public Employee
{
protected:
int sum1;
public:
Salesman():Employee();
void print();
void save();
friend class Head;
};
struck Linked
{
Employee *p;
Linked *next;
};
class Head
{
public:
Head();
void Insert(Employee *temp);
void Check();
void Delete();
void print();
~Head();
privata:
Linked *top;
};
EmployeeEmployee::Employee()
{
cout<<"输入姓名: ";
cin>>name;
++count;
num=count;
rank=1;
}
void Employee::print()
{
cout<<"编号"<<num<<" "<<"姓名"<<name<<" "<<"等级"<<rank<<" "<<"月薪"<<wages<<endl;
}
MansgerMansger::Mansger():Employee()
{
rank=4;
wages=8000;
}
void Mansger::print()
{
cout<<"编号"<<num<<" "<<"姓名"<<name<<" "<<"等级"<<rank<<" "<<"月薪"<<wages<<endl;
}
void Mansger::save()
{
ofstream fs("d:\\Mansger.txt");
fs<<wages;
cout<<"Mansger ok"<<endl;
}
SalemansgerSalemansger::Salemansger():Employee()
{
rank=3;
cout<<"输入部门销售总额: ";
cin>>sum;
wages=0.005*sum;
}
void Salemansger::print()
{
cout<<"编号"<<num<<" "<<"姓名"<<name<<" "<<"等级"<<rank<<" "<<"月薪"<<wages<<endl;
}
void Salemansger::save(){
ofstream fs("d:\\Salemansger.txt");
fs<<wages;
cout<<"Salemansger ok"<<endl;
}
TechnologyTechnology::Technology():Employee()
{
rank=3;
cout<<"输入工作时间: ";
cin>>sum;
wages=100*time;
}
void Technology::print()
{
cout<<"编号"<<num<<" "<<"姓名"<<name<<" "<<"等级"<<rank<<" "<<"月薪"<<wages<<endl;}
void Technology::save()
{
ofstream fs("d:\\Technology.txt");
fs<<wages;
cout<<"Technology ok"<<endl;
}
SalesmanSalesman::Salesman():Employee()
{
cout<<"输入月销售额: ";
cin>>sum1;
wages=0.04*sum1;
}
void Salesman::print(){
cout<<"编号"<<num<<" "<<"姓名"<<name<<" "<<"等级"<<rank<<" "<<"月薪"<<wages<<endl;}
void Salesman::save()
{
ofstream fs("d:\\Salesman.txt");
fs<<wages;
cout<<"Salesman ok"<<endl;
}
HeadHead::Head()
{
if((top=new Linked)==NULL)exit(-1_);
top->next=NULL;
}
void Head::Insert(Employee *temp)
{
Linked *ttop=top;
while(ttop->next)
ttop=ttop->next;
ttop->next=new Linked;
ttop->next->p=temp;
ttop->next->next=0;
}
void Head::Check()
{
char s[20];
cout<<"输入要查找人的姓名: ";
cin>>s;
Linked *pbuf=top->next;
while(pbuf!=NULL)
{
if(strcmp(pbuf->p->name,s)!=0)
pbuf=pbuf->next;
else if(strcmp(pbuf->p->name,s)==0
{
cout<<"编号"<<pbuf->p->num<<" "<<"姓名"<<pbuf->p->name<<" "<<"等级"<<pbuf->p->rank<<" "<<"月薪"<<pbuf->p->wages<<endl;
}
pbuf=pbuf->next;
continue;
}
elsecout<<"查无此人"<<endl;
}
void Head::Delete()
{
int a;
cout<<"输入要删除人的编号: ";
cin>>a;
Linked *pbuf=top,*q;
while(pbuf->next!=NULL)
{
if(a!=pbuf->next->p->num)
pbuf=pbuf->next;
else if(a==pbuf->next->p->num)
{
q=pbuf->next;
pbuf->next=pbuf->next->next;
delete q;
cout<<"删除成功"<<endl;
}
elsecout<<"查无此人"<<endl;
}
void Head::print()
{
Linked *pbuf=top->next;
while(pbuf!=NULL)
{
pbuf->p->print();
pbuf=pbuf->next;
}
}
Head::~Head ()
{
Linked *ttop,*q;
ttop=top->next;
while(ttop!=NULL)
{
q=ttop;
ttop=ttop->next;
delete q;
}
}void mnue(Head *Data)
{
int n;
cout<<"请输入1、查找 2、删除 3、打印 0 退出:\n";
cin>>n;
switch(n)
{
case 1:
Data->Check();
break;
case 2:
Data->Delete();
break;
case 3:
Data->print();
break;
case 0:
break;
}
cout<<"是否继续继续请按1退出请按0";
cin>>n;
if(n!=0) mnue(Data);
}
void menu(Head *Data)
{
Mansger *M;Salemansger *S;
Technology *T;
Salesman *SA;
int n;
cout<<"请输入1、经理 2、销售经理 3、技术 4、销售员 0、退出:\n";
cin>>n;
switch(n)
{
case 1:
M=new Mansger;
M->save();
Data->Insert(M);
break;
case 2:
S=new Salemansger;
S->save();
Data->Insert(S);
break;
case 3:
T=new Technology;
T->save();
Data->Insert(T);
break;
case 4:
SA=new Salesman;
SA->save();
Data->Insert(SA);
break;
case 0:break;
}
cout<<"是否继续继续请按1退出请按0";
cin>>n;
if(n!=0) mnue(Data);
}
void main()
{
Head Data;
int n;
while(1)
{
cout<<"请输入(1 输入 2 其他操作 0 退出):\n";
cin>>n;
switch(n)
{case 1:
menu(&Data);
break;
case 2:
menu(&Data);
break;
case 0:
system("pause");
return;
}
}
system("cls");
}