VC6.0中,调用已定义函数时,出现undeclared identifier,redefinition错误,这是怎么回事?
程序代码:
#include<conio.h> #include<stdio.h> #include<stdlib.h> //记录学生数 int count; //定义学生信息 struct student { int num; char name[10]; float Maths[2]; float English[2]; float Computer[2]; double finallyscore[3]; struct student *next; }; //函数声明 struct student *create(); void Delete(struct student *pHead); bool cheak2(struct student *pHead,int number); void main() { int option; struct student *pHead=NULL; printf("请选择:"); scanf("%d",&option); while(true) { switch(option) { case 1: pHead=create();break; case 3: Delete(pHead);break; case 0: exit(0);break; default : { printf("输入错误,请重新输入:"); scanf("%d",&option); } } getch(); printf("请选择:"); scanf("%d",&option); } } //创建信息 struct student *create() { struct student *pHead; struct student *pNew,*pEnd; pHead=NULL; count=0; pEnd=pNew=(struct student*)malloc(sizeof(struct student)); while(true) { printf("请输入学生信息(输入0退出)\n\n"); printf("学号:"); scanf("%d",&pNew->num); while(pNew->num<0) { printf("输入错误,请重新输入学号:"); scanf("%d",&pNew->num); getch(); } if(pNew->num==0) goto end; printf("学生姓名:"); scanf("%s",&pNew->name); printf("数学平时成绩、考试成绩:"); scanf("%f%f",&pNew->Maths[0],&pNew->Maths[1]); printf("英语平时成绩、考试:"); scanf("%f%f",&pNew->English[0],&pNew->English[1]); printf("计算机平时成绩、考试成绩:"); scanf("%f%f",&pNew->Computer[0],&pNew->Computer[1]); printf("\n"); //计算综合成绩 pNew->finallyscore[0]=pNew->Maths[0]*0.3+pNew->Maths[1]*0.7; pNew->finallyscore[1]=pNew->English[0]*0.3+pNew->English[1]*0.7; pNew->finallyscore[2]=pNew->Computer[0]*0.3+pNew->Computer[1]*0.7; count++; if(count==1) { pNew->next=pHead; pHead=pNew; pEnd=pNew; } else { pNew->next=NULL; pEnd->next=pNew; pEnd=pNew; } pNew=(struct student*)malloc(sizeof(struct student)); } end: free(pNew); return pHead; } //删除学生信息 void Delete(struct student *pHead) { int a,i; if(pHead!=NULL) { printf("请输入要删除的学生学生学号:"); scanf("%d",&a); if(check2(pHead,a)) { struct student *pTemp,*pPre; pTemp=pHead; for(i=1;i<a;i++) { pPre=pTemp; pTemp=pTemp->next; } pPre->next=pTemp->next; free(pTemp); count--; } else printf("该学生不存在!"); } else printf("该系统不存在任何信息,请先建立!"); } //检查是否存在该学生信息 bool check2(struct student *pHead,int number) { struct student *ptemp=pHead; if(pHead==NULL) { printf("没有相关学生信息\n"); return false; } else { while(ptemp!=NULL) { if(ptemp->num==number) { return true; break; } ptemp=ptemp->next; } return false; } }
C:\Users\acer\Desktop\a.cpp(121) : error C2065: 'check2' : undeclared identifier
C:\Users\acer\Desktop\a.cpp(143) : error C2373: 'check2' : redefinition; different type modifiers