|
#include <string>
#include <iostream>
using namespace std;
class stu
{
public:
stu(int a=0,int b=0):num(a),success(b){};
static void max(stu *pt);
private:
int num;
int success;
};
void stu::max(stu *pt)
{
stu *p;
int i=0,max=0;
while(i<5)
{
if(max<pt[i].success)
p=&pt[i];
i++;
}
cout<<"MAX is:"<<endl<<"NUM:"<<p->num<<"SUC:"<<p->success<<endl;
}
int main()
{
stu a[5]={stu(1001,50),
stu(1002,70),
stu(1003,80),
stu(1004,90),
stu(1005,95),
};
stu::max(a);
return 0;
} |
|