Home > Back-end >  Can help you see what is wrong
Can help you see what is wrong

Time:09-24

# include
# include
The class Student.//student
The class the Teacher;//the teacher class
The class Person//human
{
Private:
Int id;
Char name [20].
Public:
The Person (int x, char * p)
{
Id=x;
Strcpy (name, p);
}
Void show (Student s)
{
cout <"Number:" & lt; cout <"Name:" & lt; cout <"Class number:" & lt; cout <"Record:" & lt; }
Void the show () the Teacher t//show function overloading
{
cout <"Number:" & lt; cout <"Name:" & lt; cout cout <":" & lt; }
};
The class Student: public Person
{
Private:
Int every;
A double score;
Public:
Void setclassid (int x)//set the private attribute class number
{
Every x;
}
Void setscore (double y)//set up a private property grades
{
Score=y;
}
Int getclassid ()
{
Return every;
}
Double getscore ()
{
Return score;
}
};
The class the Teacher: public Person
{
Private:
Char zhicheng [10].//title
Char bumen [10].//department
Public:
Void setzhicheng (char * p)//set up a private property title
{
Strcpy (zhicheng, p);
}
Void setbumen (char * p)//set up a private property department
{
Strcpy (bumen, p);
}
Char getzhicheng ()
{
Return zhicheng.
}
Char getbumen ()
{
Return bumen;
}
};
Void main ()
{
The Person s1 (1, "small strong");
Student p1.
P1. Setclassid (15);
P1. Setscore (90.8);
S1. The show (p1);
}
  • Related