大侠来看看、帮这个程序出问题了 帮我改改
#include<iostream.h>#include<stdlib.h>
#include<fstream.h>
#include<iomanip.h>
#include<string.h>
class employee
{
public:
employee()
{
salary=0;
}
void pay(){}
void print(){}
void input()
{
cout<<"ID:";
cin>>no;
cout<<" NAME:";
cin>>name;
cout<<" SEX(m/w):";
cin>>sex;
cout<<" AGE:";
cin>>age;
}
protected:
int no;
char name[8];
float salary;
char sex;
int age;
};
class manager:virtual public employee
{
protected:
float monthlypay,sale;
public:
manager(){monthlypay=8000;}
void input(){cout<<"Manger";employee::input();}
void save()
{
fstream outfile;
outfile.open("f:flsdfj.txt",ios::app);
if(!outfile)
{
cout<<"f can't open.\n";
abort();
}
outfile<<"Manger"<<endl;
outfile<<"ID"<<no<<"NAME"<<name<<"SEX"<<sex<<"AGE"<<age<<"SALARY"<<salary<<endl;
}
void pay(){salary=monthlypay;}
void print()
{
cout<<"├─────┼─────┼─────┼─────┼─────┤"<<endl;
cout<<"│"<<setw(10)<<no<<"│"<<setw(10)<<name<<"│"<<setw(10)<<sex\
<<"│"<<setw(10)<<age<<"│"<<setw(10)<<salary<<"│"<<endl;
}
};
class technician:virtual public employee
{
private:
float hourlyrate;
int workhours;
public:
technician(){hourlyrate=100;}
void pay()
{
cout<<name<<"Work hour:";
cin>>workhours;
salary=hourlyrate*workhours;
}
void input(){cout<<"TECHNICIAN"<<endl;employee::input();}
void save()
{
fstream outfile;
outfile.open("f:flsdfj.txt",ios::app);
if(!outfile)
{
cout<<"f can't open.\n";
abort();
}
outfile<<"TECHNICIAN"<<endl;
outfile<<"ID"<<no<<"NAME"<<name<<"SEX"<<sex<<"AGE"<<age<<"SALARY"<<salary<<endl;
}
void print()
{
cout<<"├─────┼─────┼─────┼─────┼─────┤"<<endl;
cout<<"│"<<setw(10)<<no<<"│"<<setw(10)<<name<<"│"<<setw(10)<<sex\
<<"│"<<setw(10)<<age<<"│"<<setw(10)<<salary<<"│"<<endl;
}
};
class salesman:virtual public employee
{
protected:
float commrate;
float sales;
public:
salesman(){commrate=0.04;}
void input(){cout<<"SALEMAN";employee::input();}
void save()
{
fstream outfile;
outfile.open("f:flsdfj.txt",ios::app);
if(!outfile)
{
cout<<"f can't open.\n";
abort();
}
outfile<<"TECHNICIAN"<<endl;
outfile<<"ID"<<no<<"NAME"<<name<<"SEX"<<sex<<"AGE"<<age<<"SALARY"<<salary<<endl;
}
void pay()
{
cout<<name<<"Sales volume:";
cin>>sales;
salary=sales*commrate;
}
void print()
{
cout<<"├─────┼─────┼─────┼─────┼─────┤"<<endl;
cout<<"│"<<setw(10)<<no<<"│"<<setw(10)<<name<<"│"<<setw(10)\
<<sex<<"│"<<setw(10)<<age<<"│"<<setw(10)<<salary<<"│"<<endl;
}
};
class salesmanager:virtual public manager,virtual public salesman
{
private:
float total;int no1,no2,no3,no4;char name1[8],name2[8],name3[8],name4[8];
float sale1,sale2,sale3,sale4;
public:
void salemanager()
{
monthlypay=5000;
commrate=0.005;
}
void input(){cout<<"Sales manger";employee::input();}
void save()
{
fstream outfile;
outfile.open("f:flsdfj.txt",ios::app);
if(!outfile)
{
cout<<"f can't open.\n";
abort();
}
outfile<<"Sales manger"<<endl;
outfile<<"ID"<<no<<"NAME"<<name<<"SEX"<<sex<<"AGE"<<age<<"SALARY"<<salary<<endl;
}
void savesale()
{
fstream outfile;
outfile.open("f:flsdfj.txt",ios::app);
if(!outfile)
{
cout<<"f can't open.\n";
abort();
}
outfile<<"The salary of saleman of sales manger and themselves"<<endl;
outfile<<"ID"<<no1<<"NAME"<<name1<<"SALARY"<<sale1<<endl;
outfile<<"ID"<<no2<<"NAME"<<name2<<"SALARY"<<sale2<<endl;
outfile<<"ID"<<no3<<"NAME"<<name3<<"SALARY"<<sale3<<endl;
outfile<<"ID"<<no4<<"NAME"<<name4<<"SALARY"<<sale4<<endl;
}
void pay()
{
cout<<name<<"The sales volume of everydepartment:";
salary=monthlypay+commrate*total;
}
float totalsale(){total=sale1+sale2+sale3+sale4;return total;}
void printtotal()
{
cout<<"├─────┴──┬──┴─────┤"<<endl;
cout<<"│Total │ "<<setw(10)<<total<<" │"<<endl;
cout<<"└────────┴────────┘"<<endl;
}
void sort(salesmanager p)
{
int tmp,i,j;
for(j=0;j<2;j++)
for(i=0;i<2;i++)
if(total<p.salary)
{
tmp=salary;
total=p.salary;
p.salary=tmp;
tmp=no;
no=p.no;
p.no=tmp;
}
}
void saler()
{
cout<<"Staff ID:";
cin>>no1;
cout<<" Staff NAME:";
cin>>name1;
cout<<" Sales volume:";
cin>>sale1;
cout<<"Staff ID:";
cin>>no2;
cout<<" Staff NAME:";
cin>>name2;
cout<<" Sales volume:";
cin>>sale2;
cout<<"Staff ID:";
cin>>no3;
cout<<" Staff NAME:";
cin>>name3;
cout<<" Sales volume:";
cin>>sale3;
cout<<"Staff ID:";
cin>>no4;
cout<<" Staff NAME:";
cin>>name4;
cout<<" Sales volume:";
cin>>sale4;
}
void saleprint()
{
cout<<"│"<<setw(10)<<no1<<"│"<<setw(10)<<name1<<"│"<<setw(10)<<sale1<<"│"<<endl;
cout<<"├─────┼─────┼─────┤"<<endl;
cout<<"│"<<setw(10)<<no2<<"│"<<setw(10)<<name2<<"│"<<setw(10)<<sale2<<"│"<<endl;
cout<<"├─────┼─────┼─────┤"<<endl;
cout<<"│"<<setw(10)<<no3<<"│"<<setw(10)<<name3<<"│"<<setw(10)<<sale3<<"│"<<endl;
cout<<"├─────┼─────┼─────┤"<<endl;
cout<<"│"<<setw(10)<<no4<<"│"<<setw(10)<<name4<<"│"<<setw(10)<<sale4<<"│"<<endl;
}
void print()
{
cout<<"├─────┼─────┼─────┼─────┼─────┤"<<endl;
cout<<"│"<<setw(10)<<no<<"│"<<setw(10)<<name<<"│"<<setw(10)<<sex<<"│"\
<<setw(10)<<age<<"│"<<setw(10)<<salary<<"│"<<endl;
}
};
void main()
{
manager m[4];
technician t[4];
salesman s[4];
salesmanager sm[4];
t[1].save();
int flag=1,operate;
do{
cout<<" #### The system of salary manger ####\n";
cout<<" ┌─────────────┐\n";
cout<<" │ Chose your actions │\n";
cout<<" │ Input:1,Enter │\n";
cout<<" │ Total:2,Enter │\n";
cout<<" │ Output:3,Enter │\n";
cout<<" │ Save:4,Enter │\n";
cout<<" │ Exit:5,Enter │\n";
cout<<" └─────────────┘\n";
cout<<" Please chose one action: ";
cin>>operate;
switch(operate)
{
case 1:
cout<<"Waiting for a minute!"<<endl;
{
for(int i=0;i<4;i++)
{m[i].input();}
for(int j=0;j<4;j++)
{t[j].input();}
for(int k=0;k<4;k++)
{s[k].input();}
for(int l=0;l<4;l++)
{sm[l].input();}
};
{
for(int i=0;i<4;i++)
{m[i].pay();}
for(int j=0;j<4;j++)
{t[j].pay();}
for(int k=0;k<4;k++)
{s[k].pay();}
for(int l=0;l<4;l++)
{sm[l].pay();sm[l].saler();}
};break;
case 2:
cout<<"Waiting for a minute!"<<endl;
{
{
for(int l=0;l<4;l++)
sm[l].totalsale();
for(int i=0;i<4;i++)
for(int j=0;j<2;j++)
sm[j].sort(sm[j+1]);
};
cout<<"The saleman of the first sales manger"<<endl;
cout<<"┌─────┬─────┬─────┐"<<endl;
cout<<"│ ID │ NAME │ SALARY │"<<endl;
sm[0].saleprint();
sm[0].printtotal();
cout<<" The order is complete"<<endl;
cout<<"List names of every sales manger"<<endl;
cout<<"┌─────┬─────┬─────┬─────┬─────┐"<<endl;
cout<<"│ ID │ NAME │ SEX │ AGE │ SALARY │"<<endl;
for(int k=0;k<4;k++)
sm[k].print();
cout<<"└─────┴─────┴─────┴─────┴─────┘"<<endl;
};break;
case 3:
cout<<"Waiting for a minute!"<<endl;
{
cout<<" The blank of the :"<<endl;
cout<<"┌─────┬─────┬─────┬─────┬─────┐"<<endl;
cout<<"│ ID │ NAME │ SEX │ AGE │ SALARY │"<<endl;
for(int i=0;i<4;i++)
{m[i].print();}
cout<<"└─────┴─────┴─────┴─────┴─────┘"<<endl;
cout<<"┌─────┬─────┬─────┬─────┬─────┐"<<endl;
cout<<"└─────┴─────┴─────┴─────┴─────┘"<<endl;
cout<<"┌─────┬─────┬─────┬─────┬─────┐"<<endl;
cout<<"│ ID │ NAME │ SEX │ AGE │ SALARY │"<<endl;
for(int k=0;k<4;k++)
{s[k].print();}
cout<<"└─────┴─────┴─────┴─────┴─────┘"<<endl;
cout<<"┌─────┬─────┬─────┬─────┬─────┐"<<endl;
cout<<"└─────┴─────┴─────┴─────┴─────┘"<<endl;
};break;
case 4:
cout<<"Waiting for a minute!"<<endl;
{
for(int i=0;i<4;i++)
{m[i].save();}
for(int j=0;j<4;j++)
{t[j].save();}
for(int k=0;k<4;k++)
{s[k].save();}
for(int l=0;l<4;l++)
{sm[l].save();}
};cout<<" Information save! "<<endl;break;
case 5:exit(0);break;
default:cout<<"Error!Repeat again!"<<endl;
}
}while(flag=1);
}
}