设计一个函数int max(Student *arr);,用指向对象的指针作函数参数,在max函数中找出5个学生中成绩最高者,并返回值其学号。
/** Copyright (c) 2015,烟台大学计算机学院* All right reserved.* 作者:邵帅* 文件:Demo.cpp* 完成时间:2015年04月02日* 版本号:v1.0*/#include运行结果:using namespace std;class Student{public: Student(int n,double s):num(n),score(s) {}; int max(Student *arr); void show(); int get_num(); double get_score();private: int num; //学号 double score; //成绩};void Student::show(){ cout< <<" "< < maxscore) maxscore=arr[i].get_score(); j=i; } return arr[j].get_num();//返回最高成绩者的学号}
@ Mayuko