我在此代码中遇到问题。 我已经修改了很多,但是编译器总是显示错误#34;声明中的类型太多","声明未正确结束"和"多重声明"。 请帮我。 注意:这只是代码的开头。由于局限性,我无法发布完整的代码。 如果你愿意,我会把它寄给你......
#include <conio.h>
#include <iomanip.h>
#include <string.h>
#include <iostream.h>
#define HR for(j=0;j<80;j++) cout<<"-";
#define SR for(j=0;j<80;j++) cout<<"=";
#define NEWLINE cout<<"\n";
class stud {friend class getrec;friend class sortrec;friend class list;friend class search;friend class edit;friend class delrec;}
class getrec{public:void f(class stud);};
class sortrec{public:void f(class stud);};
class list{public:void f(class stud);};
class search{public:void f(class stud);};
class edit{public:void f(class stud);};
class delrec{public:void f(class stud);};
struct student
{
char name[20],sub[10];
long roll,code;
int internal,external;
}
class stud
{
friend class getrec;
friend class sortrec;
friend class list;
friend class search;
friend class edit;
friend class delrec;
private:
int choice,i,j,c,cur,b,rec;
//char name[20];
struct student e[96],t;
public:
stud()
{
for (c=0;c<96;c++)
{
e[i].internal=0;
e[i].external=0;
e[i].roll=-1;
e[i].code=0;
strcpy(e[i].name,"");
strcpy(e[i].sub,"");
}
}
int menu(void)
{
clrscr();
cout<<"\tThe Database Management System of Employees"<<endl;
cout<<"Choose any of these options by pressing any of their corresponding numbers"<<endl;
cout<<"1. List he records."<<endl;
cout<<"2. Delete old record."<<endl;
cout<<"3. Insert new record."<<endl;
cout<<"4. Edit record."<<endl;
cout<<"5. Search for a record."<<endl;
cout<<"6. Sort entries."<<endl;
cout<<"7. Quit."<<endl;
choice=getch();
return choice;
}
~stud()
{
clrscr();
cout<<"The Database has been deleted.";
getch();
}
void program(void)
{
do
{
menu();
switch (choice)
{
case '1':
list();
break;
case '2':
delrec();
break;
case '3':
getrec();
break;
case '4':
edit();
break;
case '5':
search();
break;
case '6':
sortrec();
break;
}
} while (choice!='7');
}
void getrec(class getrec g)
{
g.f();
}
void sortrec(class sortrec s)
{
s.f();
}
void list(class list l)
{
l.f();
}
void search(class search s)
{
s.f();
}
void edit(class edit e)
{
e.f();
}
void delrec(class delrec d)
{
d.f();
}
}
答案 0 :(得分:-1)
使用分号跟随类和结构声明。它用于声明该类型的变量,以及typedef。