求助大神,如何在类的对象中编写一个比较函数,比较total最大值,输出最大值的值和姓名?
#include<iostream>using namespace std;
class teacher
{
public:
teacher(char s[10],int a,int b,int c,int d);
private:
char name[10];
int wage;
int fwage;
int bonus;
int total;
};
teacher::teacher(char s[10],int a,int b,int c,int d)
{
strcpy(name,s);
wage=a;
fwage=b;
bonus=c;
d=a+b+c;
total=d;
}
void main()
{
teacher teach[5]={teacher("贾宇",2300,1980,2000,0),teacher("张莹",1908,2000,1000,0),teacher("李蒙",2490,1080,980,0),
teacher("王同辽",980,1200,680,0),teacher("叶库伦",1290,1800,390,0)};
teacher*q=teach;
}