#include<iostream>
using namespace std;
class Student{
public:
Student(int i,int s)
{id=i;
score=s;
}
private:
int id;
int score;
friend void max(Student *p);
};
void max(Student *p)
{int b,i,x;
b=p[0].score;
for(i=0;i<6;i++)
{if(b<p[i].score)
b=p[i].score;
i=x;
}
cout<<"The id is:"<<p[x].id<<endl;
}
int main()
{Student stu[6]={Student(1,91),Student(2,92),Student(3,93),Student(4,94),Student(5,95),Student(6,96)};
max(stu);
return 0;
}
老师您好,这个程序检查的时候显示没有错误,但运行的时候却不能运行,情况如下图,请老师指点。