学生管理系统
#include <iostream>
using namespace std;
class People
{
protected:
string m_name, m_xing;
int m_num, m_shen, m_sumstd, m_std;
public:
virtual void Show();
virtual void Input();
};
void People::Input()
{
cin >> m_name >> m_num >> m_xing >> m_shen >> m_sumstd >> m_std;
}
void People::Show()
{
cout << m_name << "\t"
<< m_num << "\t"
<< m_xing << "\t"
<< m_shen << "\t\t"
<< m_sumstd << "\t"
<< m_std << "\t";
}
class Student :public People
{
public:
virtual void Show();
virtual void Input();
};
void Student::Show()
{
People::Show();
cout << endl;
}
void Student::Input()
{
People::Input();
}
class Teacher : public People
{
protected:
int m_tchtime;
public:
virtual void Input();
virtual void Show();
};
void Teacher::Show()
{
People::Show();
cout << " \t\t" << m_tchtime << endl;
}
void Teacher::Input()
{
People::Input();
cin >> m_tchtime;
}
class Graduate : public Student
{
protected:
int m_seartime;
public:
virtual void Show();
virtual void Input();
};
void Graduate::Show()
{
People::Show();
cout << "\t" << m_seartime << "\t";
cout << endl;
}
void Graduate::Input()
{
Student::Input();
cin >> m_seartime;
}
class TA : public Graduate, public Teacher, public People
{
public:
void Show();
void Input();
};
void TA::Show()
{
People::Show();
cout << "\t" << m_seartime << "\t\t"
<< m_tchtime << endl;
cout << endl;
}
void TA::Input()
{
People::Input();
cin >> m_seartime;
cin >> m_tchtime;
}
void out()
{
cout << "姓名" << "\t"
<< "学号" << "\t"
<< "性别" << "\t"
<< "身份证号码" << "\t"
<< "总学时" << "\t"
<< "每周学时" << "\t";
}
int main()
{
cout << "\t\t*****欢迎来到管理系统******\t\t" << endl;
int choice = 0, size = 100, i = 0;
People* arr[100];
while (choice != 6)
{
cout << "——————————————————————————————————————\n";
cout << "1、本科生信息录入 2、教师信息录入 "
<< "3、研究生信息录入 4、助教信息录入\n"
<< "\t\t5、显示信息 6、退出系统\t\t" << endl << endl;
cout << "请输入想要进行操作的数字:";
cin >> choice;
cout << endl;
switch (choice)
{
//本科生
case 1:
arr[i] = new Student();
out();
cout << endl;
arr[i]->Input();
++i;
cout << endl;
break;
//教师
case 2:
arr[i] = new Teacher();
out();
cout << "教学时长" << endl;
arr[i]->Input();
++i;
cout << endl;
break;
//研究生
case 3:
arr[i] = new Graduate();
out();
cout << "研究时长\n";
arr[i]->Input();
++i;
cout << endl;
break;
//助教
case 4:
arr[i] = new TA();
out();
cout << "教学时长\t" << "研究时长\n";
arr[i]->Input();
++i;
cout << endl;
break;
case 5:
for (int j = 0; j < i; ++j)
{
cout << endl;
cout << "姓名" << "\t"
<< "学号" << "\t"
<< "性别" << "\t"
<< "身份证号码" << "\t"
<< "总学时" << "\t"
<< "每周学时" << "\t"
<< "研究时长\t" << "教学时长\n";
arr[j]->Show();
}
break;
case 6:
cout << "Thank!" << endl;
break;
}
}
}