#include<iostream>
#include<string>
using namespace std;
class Base{
public:
string name;
int age;
};
class Student:public Base{
public:
Student *s;
float Chinese;
float math;
float score;
Student();
~Student();
void output();
void compute(Student &s);
string getname();
};
class Teacher:public Base{
public:
Teacher *t;
~Teacher();
string level1;
float salary;
void output();
void compute(Teacher &t);
string getname();
};
class Worker:public Base{
public:
~Worker();
Worker *w;
int level2;
float salary;
void output();
void compute(Worker &w);
string getname();
};
class Leader:public Teacher,public Worker{
string name;
int age;
Leader *l;
public:
Leader(){};
Leader(string name,int age,string level1,string level2){};
float salary;
void output();
string getname();
void compute();
};
Student::Student()
{
this->name = name;
this->age = age;
}
string Student::getname()
{
return name;
}
void Student::compute(Student &s){
s.score=Chinese+math;
}
void Student::output(){
cout << "請輸入要查找的學生姓名" << endl;
string name;
cin >> name;
for (int i = 0; i < 100; i++)
{
if (s[i].getname() == name) {
cout<<name<<" "<<age<<" "<<Chinese<<" "<<math<<" "<<score<<endl;
return;
}
}
cout << "未查詢到結果" << endl;
}
string Teacher::getname(){
return name;
}
void Teacher::compute(Teacher &t){
string level1;
if (level1=="講師"){
t.salary=4000;}
if (level1=="副教授"){
t.salary=5000;}
if (level1=="教授"){
t.salary=6000;}
}
void Teacher::output(){
cout << "請輸入要查找的教師姓名" << endl;
string name;
cin >> name;
for (int i = 0; i < 100; i++)
{
if (t[i].getname() == name) {
cout<<name<<" "<<age<<" "<<level1<<" "<<salary<<" "<<endl;
return;
}
}
cout << "未查詢到結果" << endl;
}
string Worker::getname(){
return name;
}
void Worker::compute(Worker &w){
int level2;
if (level2=1){
w.salary=2000;}
if (level2=2){
w.salary=3000;}
if (level2=3){
w.salary=4000;}
}
void Worker::output(){
cout << "請輸入要查找的職員姓名" << endl;
string name;
cin >> name;
for (int i = 0; i < 100; i++)
{
if (w[i].getname() == name) {
cout<<name<<" "<<age<<" "<<level2<<" "<<salary<<" "<<endl;
return;
}
}
cout << "未查詢到結果" << endl;
}
string Leader::getname(){
return name;
}
void Leader::compute(){
Leader::salary=Teacher::salary()+Worker::salary()/2;
}//報錯在這里錯誤 2 error C2064: 項不會計算為接受 0 個引數的函式
12 IntelliSense: 運算式必須具有 (pointer-to-) 函式型別
void Leader::output(){
cout << "請輸入要查找的領導姓名" << endl;
string name;
cin >> name;
for (int i = 0; i < 100; i++)
{
if (l[i].getname() == name) {
cout<<name<<" "<<age<<" "<<salary<<" "<<endl;
return;
}
}
cout << "未查詢到結果" << endl;
}
int main(){
int a;
while (a != 0)
{
cout << "\n\n 班級學生績點管理系統 \n\n ";
cout << "1.查詢學生資訊 \n";
cout << "2.查詢教師資訊 \n";
cout << "3.查詢職員資訊 \n";
cout << "4.查詢領導資訊 \n";
cout << "6.退出系統 \n";
cout << "請選擇操作";
int choice;
cin >> choice;
switch (choice)
{//這里開始全部case報錯錯誤 3 error C2143: 語法錯誤 : 缺少“;”(在“.”的前面)
case 1:
Student.output;
break;
case 2:
Teacher.output;
break;
case 3:
Worker.output;
break;
case 4:
Leader.output;
break;
};
}
}
非常急用,如果能夠幫忙真的非常感謝OTZ
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/183405.html
標籤:新手樂園
上一篇:移動小游戲
