#include #include //not used in this code #include using namespace std; class Student //create class Student { private: static const int maxCourses=3; int id; int count_course; //course number double grades[maxCourses]; //scores std::string name; std::string courseNames[maxCourses]; public: Student() {} //default constructor Student(int _id, double _grades[], string _name, string _courseNames[], int _count_course) //constructor with parameters { id = _id; name = _name; count_course = _count_course; for(int i=0;i= 3) return 0; //if out of range courseNames[count_course] = courseName; grades[count_course] = grade; count_course++; return 1; } void SetGrade(const string& courseName, double grade) { for(int i=0;i<=2;i++) { if(courseNames[i] == courseName) grades[i] = grade; } } double GetGrade(const string& courseName) const { for(int i=0;i<=2;i++) { if(courseNames[i] == courseName) return grades[i]; } } double GetAverageGrade() const { int i=0; double aver=0.0; for(i=0;i= maxStudent) return 0; students[StudentClass::studentCount] = new Student(*student); StudentClass::studentCount++; return 1; } void ShowStudent(int _id) const { for(int i=0;iid == _id) { cout<name<id, students[j]->id)) a = j; } //int temp=students[a]->id; not only to exchange id //students[a]->id = students[i]->id; //students[i]->id = temp; Student* temp=students[a]; students[a] = students[i]; students[i] = temp; } cout<get_id()<get_name(); for(int j=0;jGetGrade(students[i]->get_course(j)); cout<b;} int StudentClass::studentCount=0; //assignment of static variable int main() //test (may not cover all functions by accident) { string course_name[3]={"Robotics", "C++", "Math"}, class_name="class one"; double grade_wang[3]={89.5, 78.5,90.5}; double grade_li[3]={84.5, 93.5, 75.5}; double grade_zhao[3]={63.5, 99.5, 86.5}; Student student1(1, grade_wang, "Wang", course_name, sizeof(grade_wang)/sizeof(double)); Student student2(2, grade_li, "Li", course_name, sizeof(grade_li)/sizeof(double)); Student student3(3, grade_wang, "Zhao", course_name, sizeof(grade_zhao)/sizeof(double)); Student* students[3]={&student1, &student2, &student3}; StudentClass class1(class_name, students, 3); cout<get_id()<get_name(); for(int j=0;jGetGrade(students[i]->get_course(j)); cout<