c++ 如下 兄弟姐妹们能不能解答一下呀 thank u

定义一个基类有姓名、性别、年龄,再由基类派生出教师类和学生类。教师类增加工号、职称和工资,学生类增加学号、班级、专业和入学成绩。
编程要求:
1、设计虚函数输出教师和学生的基本信息;
2、计算教师的平均工资并输出;
3、使用友元函数重载运算符“、”,找出入学成绩最高的学生并输出;

#include <iostream>
#include <string>

using namespace std;

class Person
{
protected:
    string name;
    string gender;
    int age;
public:
    Person(string n, string g, int a)
    {
        name = n;
        gender = g;
        age = a;
    }
    virtual void showInfo()
    {
        cout << "Name: " << name << "\nGender: " << gender << "\nAge: " << age << endl;
    }
};

class Teacher : public Person
{
private:
    int empID;
    string title;
    int salary;
public:
    Teacher(string n, string g, int a, int id, string t, int s) : Person(n,g,a)
    {
        empID = id;
        title = t;
        salary = s;
    }
    void showInfo() override
    {
        Person::showInfo();
        cout << "Employee ID: " << empID << "\nTitle: " << title << "\nSalary: " << salary << endl;
    }
    friend double averageSalary(Teacher *tArray, int size);
};

double averageSalary(Teacher *tArray, int size)
{
    int sum = 0;
    for (int i = 0; i < size; i++)
    {
        sum += tArray[i].salary;
    }
    return (double)sum / size;
}

class Student : public Person
{
private:
    int stuID;
    string className;
    string major;
    int score;
public:
    Student(string n, string g, int a, int id, string c, string m, int s) : Person(n,g,a)
    {
        stuID = id;
        className = c;
        major = m;
        score = s;
    }
    void showInfo() override
    {
        Person::showInfo();
        cout << "Student ID: " << stuID << "\nClass Name: " << className << "\nMajor: " << major << "\nScore: " << score << endl;
    }
    friend Student operator<(Student& s1, Student& s2);
};

Student operator<(Student& s1, Student& s2)
{
    if (s1.score > s2.score)
    {
        return s1;
    }
    else
    {
        return s2;
    }
}

int main()
{
    // 初始化教师和学生
    Teacher t1("John", "Male", 35, 1001, "Associate Professor", 80000);
    Teacher t2("Amy", "Female", 45, 1002, "Professor", 100000);
    Teacher t3("David", "Male", 28, 1003, "Lecturer", 60000);

    Student s1("Tom", "Male", 20, 20231001, "Class 2", "Computer Science", 90);
    Student s2("Lucy", "Female", 19, 20231002, "Class 2", "Software Engineering", 95);
    Student s3("Peter", "Male", 21, 20231003, "Class 1", "Information Management", 88);

    // 输出所有人的信息
    cout << "Teacher 1 information:" << endl;
    t1.showInfo();
    cout << endl;
    cout << "Teacher 2 information:" << endl;
    t2.showInfo();
    cout << endl;
    cout << "Teacher 3 information:" << endl;
    t3.showInfo();
    cout << endl;
    cout << "Student 1 information:" << endl;
    s1.showInfo();
    cout << endl;
    cout << "Student 2 information:" << endl;
    s2.showInfo();
    cout << endl;
    cout << "Student 3 information:" << endl;
    s3.showInfo();
    cout << endl;

    // 计算所有教师的平均工资
    Teacher tArray[3] = {t1,t2,t3};
    double avgSalary = averageSalary(tArray, 3);
    cout << "The average salary of all teachers is: " << avgSalary << endl;

    // 找到入学成绩最高的学生
    Student result = s1 < s2 < s3;
    cout << "The student with the highest exam score is: " << result.name << endl;

    return 0;
}

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^