Home > Back-end >  Pray god to help me see where is wrong
Pray god to help me see where is wrong

Time:09-26

# include & lt; iostream>
using namespace std;

The class Person
{
Private:
Protected:
String name;
char sex;
int age;
Public:
Person (string n="zhang", char s='f', int a=0) {
Name=n;
Sex=s;
Age=a;
}
The Person (Person& A) {
This - & gt; Name=a.n ame.
This - & gt; Sex=a.s ex;
This - & gt; Age=a.a ge;
}
Void copy (Person & amp; A)
{
This - & gt; Name=a.n ame.
This - & gt; Sex=a.s ex;
This - & gt; Age=a.a ge;
}
Void the display () {
Cout<" Name: "& lt; }
};
The class Student: public Person {
Protected:
Float CPP;
int count;//a maximum of 10
Public:
Student (string n="zhang", char s='f', int a=0, float cp=0, int co=0)
: Person (n, s, a) {
CPP=cp;
The count=co;
}
Float score () {
If (count
=5)Return the CPP * 0.9;
The else
Return the CPP * 0.9 + count;
}
Void the Display () {
Cout<" Name: "& lt; "}
Void copy (Student & amp; A) {
This - & gt; Name=a.n ame.
This - & gt; Sex=a.s ex;
This - & gt; Age=a.a ge;
This - & gt; CPP=a.c pp;
This - & gt; Count=a.c mount.
}
};
The class the Teacher: public Person {
Protected:
Int id;
Student st [100];
int num;
Public:
The Teacher (string n="zhang", char s='g', int a=0, int d=1540) : //there is always an error
The Person (n, s, a) {

Id=d;
Num=0;
}
Void the Add (Student & amp; A) {
St [num]. Copy (a);
num++;
}
Void the Display () {
Cout<" Teacher's name: "& lt; <" Teach classes: "& lt; for(int i=0; iSt [I]. The Display ();
}

};
Int main ()
{
The Teacher T1 (" Ming ", "m", 20154, 012); //there is always an error
Student S1 (" zhang ", 'm', 19).
Student S2 (" Ming ", 'm', 20).
T1. Add (S1);//add students to teachers taught class
T1. The Add (S2);
T1. The Display ();
return 0;
}
  • Related