C++ 我的C++;代码不工作(用于类声明)
我的代码有问题。 我对它做了很多修改,但编译器总是显示“声明中的类型太多”、“声明结束不正确”和“多个声明”的错误。 请帮帮我。 注意:这只是代码的开始。由于限制,我无法发布完整的代码。 如果你愿意,我会寄给你C++ 我的C++;代码不工作(用于类声明),c++,class,oop,forward-declaration,C++,Class,Oop,Forward Declaration,我的代码有问题。 我对它做了很多修改,但编译器总是显示“声明中的类型太多”、“声明结束不正确”和“多个声明”的错误。 请帮帮我。 注意:这只是代码的开始。由于限制,我无法发布完整的代码。 如果你愿意,我会寄给你 #include <conio.h> #include <iomanip.h> #include <string.h> #include <iostream.h> #define HR for(j=0;j<80;j++) cout&l
#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();
}
}
#包括
#包括
#包括
#包括
#定义HR for(j=0;j在类和结构声明后面加一个分号。它用于声明该类型的变量和typedefs。类定义需要在右括号后面加一个分号。如struct student{…}
请逐字公布确切的编译器错误。另外,请确切告诉我们您使用的编译器(以及版本),并告诉我们您在什么平台上编译。类stud{friend class getrec;friend class sortrec;friend class list;friend class search;friend class edit;friend class delrec;}不正确。前向声明不需要指定任何内部细节。<代码>类螺栓;就足够了。强烈建议将编译器从Turbo C++升级到不到25年的时间。目标是5-6年后,TopeTM。更容易找到学习材料,当你发现自己工作时更相关。讨厌你。如果你还没有一个,你还没有完成你的初始调试。也在DOS仿真器上Turbo C++。好的。把我带回到ER,在我出生之前。我没有放分号吗?不,不是在每个类/结构的卷筒括号之后。例如:<代码>结构AB {int A;int b};< /Cord>是的,类后柱{}。但我尝试了转发声明,它给了我一个错误