老是找不出错误所在好郁闷啊。 #include<iostream> using namespace std; const MAXNUM=100; typedef int KeyType; typedef int DataType; typedef struct { KeyType key; DataType info; }RecordNode;
typedef struct { RecordNode record[MAXNUM]; int n; //n记录数据的个数,n<MAXNUM }SortObject;
void selectSort(SortObject *pvector) { int i,j,k; RecordNode temp; for(i=0;i<pvector->n-1;i++) { k=i; for(j=i+1;j<pvector->n;j++) if(pvector->record[j].key<pvector->record[k].key) k=j; if(k!=i) { temp=pvector->record[i]; pvector->record[i]=pvector->record[k]; pvector->record[k]=temp; } } }
int main() { int A[10]={45,7878,46545,78,56,48,8,659,45,23456}; SortObject *object; object->n=10; for(int i=0;i<object->n;i++) object->record[i].key=A[i]; selectSort(SortObject *object); //cpp(44) : error C2275: 'SortObject' : illegal use of this type as an expression for(int j=0;j<object->n;i++) cout<<object->record[j].key<<" "; cout<<'\n'; return 0; }
//cpp(44) : error C2275: 'SortObject' : illegal use of this type as an expression 大家帮小弟一下,谢谢。