2 imonkeyi imonkeyi 于 2017.09.07 15:50 提问

c++ 错误 c+++++++++++++++++++

#include
#include
#include
#include
using namespace std;
const int TMAX = 50;
class Person //基类
{
public:
int num; //编号
string name; //姓名
string sex; //性别
int age; //年龄
Person(int n = 0, string nm = " ", string s = " ", int a = 0) :num(n), name(nm), sex(s), age(a) {};//默认参数构造函数
//void Input() {};//输入成员信息
//void Output() {};//输出成员信息
int GetNum()//获得成员编号
{
return num;
}
string GetName()//获得成员姓名
{
return name;
}
};
class Teacher :virtual public Person//教师类
{
public:
string depart;//部门
string major;//专业
string job;//职业
//int choice1;//选择成员部门
//int choice2;//选择成员性别
Teacher(int n = 0, string nm = " ", string s = " ", int a = 0, string d = "电子系", string mj = "", string jb = "")
:Person(n, nm, s, a), depart(d), major(mj), job(jb) {};
void Input()//出入各数据成员
{
cout << "input the num" << endl;
cin >> num;
cout << "input the name" << endl;
cin >> name;
cout << "input the sex" << endl;
cin >> sex;
//cout << "(1.男 2.女)" << endl;
//cout << "请输入你的选择" << endl;
//cin >> choice2;
//switch (choice2)
//{
//case 1:sex = "男"; break;
//case 2:sex = "女"; break;
//default:cout << "输入错误" << endl; break;
//}
cout << "input the age" << endl;
cin >> age;
cout << "input the depart" << endl;
cin >> depart;
//cout << setw(10);
//cout << "1.电子系" << "2.机械系" << "3.经管系" << "4.土木系" << "5.计算机系" << "6.外语系"
// << "7.财会系" << "8.材料系" << "9.文法系" << endl;
//cout << "请输入你的选择" << endl;
//cin >> choice1;
//switch (choice1)
//{
//case 1:depart = "电子系"; break;
//case 2:depart = "机械系"; break;
//case 3:depart = "经管系"; break;
//case 4:depart = "土木系"; break;
//case 5:depart = "计算机系"; break;
//case 6:depart = "外语系"; break;
//case 7:depart = "财会系"; break;
//case 8:depart = "材料系"; break;
//case 9:depart = "文法系"; break;
//default:cout << "输入错误" << endl; break;
//}
cout << "input the major" << endl;
cin >> major;
cout << "input the job" << endl;
cin >> job;
}
void Output()//输出个数据成员
{
cout << setw(10);
cout << num << name << sex << age << depart << major << job << endl;

}

};
class Staff :virtual public Person//行政人员类
{
public:
string zzmm;//政治面貌
string zc;//职称
//int choice2;//选择成员性别
Staff(int n = 0, string nm = "", string s = "男", int a = 0, string z = "", string zc = "")
:Person(n, nm, s, a), zzmm(z), zc(zc) {}; //构造函数
void Input()//输入各数据成员函数
{
cout << "input the num" << endl;
cin >> num;
cout << "input the name" << endl;
cin >> name;
cout << "input the sex" << endl;
cin >> sex;
//cout << "(1.男 2.女)" << endl;
//cout << "请输入你的选择" << endl;
//cin >> choice2;
//switch (choice2)
//{
//case 1:sex = "男"; break;
//case 2:sex = "女"; break;
//default:cout << "输入错误" << endl; break;
//}
cout << "input the age" << endl;
cin >> age;
cout << "input the zzmm" << endl;
cin >> zzmm;
cout << "input the zc" << endl;
cin >> zc;
}
void Output()//输出各数据成员函数
{
cout << setw(10);
cout << num << name << sex << age << zzmm << zc << endl;
}
};
class Staf_Manage //行政人员功能类
{
Staff Sta[TMAX]; //TMAX为常量,为数组中可储存的行政人员记录的最大值
int top; //表示当前系统中储存的记录个数
Staf_Manage() //初始时记录的个数为0,所以设置top=0
{
top = 0;
}
void Add(); //实现该类记录的添加
void Show(); //实现该类所有记录的显示

void Seacher(); //实现该类记录的查询
void Edit(); //实现该类记录的修改
void Delete(); //实现该类记录的删除
void Total(); //实现该类记录的统计
void Save(); //实现该类记录的保存
void Read(); //实现该类记录的读取
};
void Staf_Manage::Add()//添加行政人员成员数据的函数
{
if (top >= TMAX)
{
cout << "用户已满" << endl;
}
Staff t;
cout << "输入新添加的人员的信息" << endl;
t.Input();
for (int i = 0; i if (t.GetNum() == Sta[i].GetNum())
{
cout }
Sta[top] = t;
top = top + 1;
cout }
void Staf_Manage::Show()//显示行政人员成员数据的函数
{
if (top == 0)
{
cout }
cout cout for (int i = 0; i Sta[i].Output();
}
void Staf_Manage::Seacher()//查找行政人员成员数据的函数
{
if (top == 0)
{
cout }
int choice;
cout cin >> choice;
switch (choice)
{
case 1: {
cout << "请输入要查找的编号" << endl;
int num;
cin >> num;
for (int i = 0; i < top; i++)
{
if (Sta[i].GetNum() == num)
{
Sta[i].Output();
}
}
cout << "查无此人" << endl;
}break;
case 2: {
cout << "请输入要查找的姓名" << endl;
string name;
cin >> name;
for (int i = 0; i {
if (Sta[i].GetName() == name)
{
Sta[i].Output();
}
}
cout }break;
default:cout }
void Staf_Manage::Delete()//删除行政人员成员数据的函数
{
if (top == 0)
{
cout }
cout int choice;
cin >> choice;
switch (choice)
{
case 1:
{
cout << "请输入编号:";
int num;
cin >> num;
for (int i = 0; i < top; i++)
{
if (num == Sta[i].num)
{
cout << "是否确认删除? 1.是 2.否 " << endl;
int choice;
cin >> choice;
switch (choice)
{
case 1:
{
for (int j = i; j < top - 1; j++)
Sta[j] = Sta[j + 1];
cout << "删除成功!" << endl;
top--;
}; break;
case 2:return; break;
default:cout << "无此项,失效!" << endl; break;
}
}
}
cout << "无此人!" << endl;
}; break;
case 2:
{
cout << "请输入姓名:";
string name;
cin >> name;
for (int i = 0; i < top; i++)
{
if (name == Sta[i].name)
{
cout << "是否确认删除? 1.是 2.否 " << endl;
int choice;
cin >> choice;
switch (choice)
{
case 1:
{
for (int j = i; j < top - 1; j++)
Sta[j] = Sta[j + 1];
cout << "删除成功!" << endl;
top--;
}; break;
case 2:return;
default:cout << "无此项,失效!" << endl; break;
}
}
}
cout << "无此人!" << endl;
}; break;
default:cout << "没有此项,失效!" << endl; break;
}
}
void Sta_Manage::Edit()//修改行政人员成员数据的函数
{
if (top == 0)
{
cout << "当前系统中没有存储记录!" << endl;
}
int num;
cout << "请输入要查找的行政人员编号:" << endl;
cin >> num;
for (int i = 0; i < top; i++)
{
if (Sta[i].GetNum() == num)
{
cout << "请对这位行政人员的信息进行修改:" << endl;
Sta[i].Input();
cout << "修改成功" << endl;
}
}
cout << "查无此人" << endl;
}
void Sta_Manage::Total()//统计行政人员成员数据的函数
{
cout << "1. 按人数统计 2.按性别统计 " << endl;
int choice;
cout << "请输入你的选择" << endl;
cin >> choice;
switch (choice)
{
case 1:cout << "行政人员类数量为:" << top << endl; break;
case 2:
{
int a = 0, b = 0;
for (int i = 0; i < top; i++)
{
if (Sta[i].sex == "男")a++;
if (Sta[i].sex == "女")b++;
}
cout << "男性人数为" << a << endl;
cout << "女性人数为" << b << endl;
}; break;
default:cout << "输入错误,请重新输入" << endl; break;
}
}
void Sta_Manage::Save()//存储行政人员成员数据的函数
{
ofstream out("D:\ying3.txt", ios::out);
if (!out)
{
cout << "打开失败!" << endl;
return 0;
}
cout << "打开成功!" << endl;
for (int i = 0; i < top; i++)
{
out << Sta[i].num << "" << Sta[i].name << "" << Sta[i].sex << "" << Sta[i].age
<< "" << Sta[i].zzmm << "" << Sta[i].zc << endl;
}
cout << "写入成功!" << endl;
out.close();
}
void Sta_Manage::Read()//读出行政人员成员数据的函数
{
ifstream in("D:\ying3.txt", ios::in);
if (!in)
{
cout << "打开失败!" << endl;
return 0;
}
int i = 0;
while (in << Sta[i].num << "" << Sta[i].name << "" << Sta[i].sex << "" << Sta[i].age
<< "" << Sta[i].zzmm << "" << Sta[i].zc)
{
Sta[i].Output();
i++;
top++;
}
in.closs();
};

其他的没可以不看   为了方便一起复制了
为什么错了哪么多
Csdn user default icon
上传中...
上传图片
插入图片