#include #include using namespace std; //Score类 class Score { private: int math; int eng; public: // 构造函数,初始化 math 和 eng Score(int m, int e) { math = m; eng = e; } // 成员函数,输出数学成绩和英语成绩 void show() { cout << "数学成绩:" << math << endl; cout << "英语成绩:" << eng << endl; } }; //Student类 class Student { private: int stuid; Score mark; public: // 构造函数,初始化 stuid 和 mark Student(int id, int m, int e) : stuid(id), mark(m, e) {} // 成员函数,输出学号和成绩 void stushow() { cout << "\n学号:" << stuid << endl; mark.show(); // 调用 Score 类中的 show() 函数 } }; int main() { int id, math, eng; // 输入学生的学号、数学成绩、英语成绩 cout << "学号:"; cin >> id; cout << "数学成绩:"; cin >> math; cout << "英语成绩:"; cin >> eng; // 创建 Student 对象并输出 Student student(id, math, eng); student.stushow(); return 0; return 0; }