求帮忙找下哪里错了。。。
c++吧
全部回复
仅看楼主
level 8
he8660123 楼主
代码:
#include<iostream.h>
#include<string.h>
struct student{
char num[8];
char name[10];
short grade;
};
template<class Type> Type findmax(Type a[],int n);
char*findmax(char*a[],int n);
int operator>(student&x,student&y); void main()
{
int a1[8]={35,26,48,69,60,35,83,55};
char*a2[6]={"GULIANG","NINGCHEN","XUXKAI","WEIRONG",
"CUICHA","WANGPING"};
student a3[5]={{"cs102","张平",74},{"ch231","王广敏",89},
{"ec115","刘文",62},{"pt327","古明",75},
{"bx214","张文远",68}};
int b1=findmax(a1,8);
char*b2=findmax(a2,6);
student b3=findmax(a3,5);
cout<<b1<<endl;
cout<<b2<<endl;
cout<<b3.num<<' '<<b3.name<<' '<<b3.grade<<endl;
}
template<class Type>
Type findmax(Type a[],int n)
{
Type max=a[0];
for(int i=0;i<n;i++)
if(a[i]>max)max=a[i];
return max;
}
char*findmax(char*a[],int n)
{
char*max=a[0];
for(int i=1;i<n;i++)
if(strcmp(a[i],max)>0)max=a[i];
return max;
}
bool operator>(const student&x,const student&y)
{
return x.grade>y.grade;
}
错误:
第二.obj : error LNK2001: unresolved external symbol "int __cdecl operator>(struct student &,struct student &)" (??O@YAHAAUstudent@@0@Z)
Debug/第二.exe : fatal error LNK1120: 1 unresolved externals
2012年07月18日 01点07分 1
1