2種改法,壹是把friend int compare(student &s1,student &s2)函數變成類外部函數,壹種是修改
if(compare(stu[max],stu[i]}==-1)的用法,應該改為
friend int compare(student &s2) {
f(age>s2.age)
return 1;
else if(age==s2.age)
return 0;
else return-1;
}
而調用方法則改為:
if (stu[max].compare(stu[i])==-1)
...