一个c++错误请大家指点
#include<iostream>using namespace std;
#include"student.h"
int main()
{ void max(student *p1);
student stud[3]={student(1,56.8),student(2,89.3),student(3,78.3)},*p=stud;
max(stud);
return 0;
}
void max(student *p1)
{int i,j;
double t;
for(i=0;i<2;i++)
for(j=i+1;j<3;j++)
if(*(p1+i)<*(p1+j))
{t=p1[i];p1[i]=p1[j];p1[j]=t;}
}
其中红色部分提示一下错误:
D:\c++\ex3_h51\f.cpp(16) : error C2784: 'bool __cdecl std::operator <(const class std::reverse_iterator<_RI,_Ty,_Rt,_Pt,_D> &,const class std::reverse_iterator<_RI,_Ty,_Rt,_Pt,_D> &)' : could not deduce template argument for 'const class std::revers
e_iterator<_RI,_Ty,_Rt,_Pt,_D> &' from 'class student'
D:\c++\ex3_h51\f.cpp(16) : error C2784: 'bool __cdecl std::operator <(const struct std::pair<_T1,_T2> &,const struct std::pair<_T1,_T2> &)' : could not deduce template argument for 'const struct std::pair<_T1,_T2> &' from 'class student'
D:\c++\ex3_h51\f.cpp(16) : error C2676: binary '<' : 'class student' does not define this operator or a conversion to a type acceptable to the predefined operator
D:\c++\ex3_h51\f.cpp(17) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class student' (or there is no acceptable conversion)
D:\c++\ex3_h51\f.cpp(17) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'double' (or there is no acceptable conversion)
Error executing cl.exe.
我是初学者,请指教!