E:\5465.cpp(80) : fatal error C1004: unexpected end of file found

#include<iostream>usingnamespacestd;classperson{private:charname[20];intnumber;public... #include<iostream>
using namespace std;
class person
{
private:
char name[20];
int number;
public:
void Getperson()
{
cout<<"请输入名字:";
cin>>name;
cout<<"请输入学号:";
cin>>number;
}
void Showperson()
{
cout<<"姓名:"<<name<<endl;
cout<<"学号:"<<number<<endl;
}
};
class student:public person
{
private:
float score;
char clas;
public:
void Getstudent()
{
cout<<"请输入成绩:";
cin>>score;
cout<<"请输入班级:";
cin>>clas;
}
void Showstudent()
{
cout<<"成绩:"<<score<<endl;
cout<<"班级:"<<clas<<endl;
}
};
int main()
{
student A;
A.Getperson();
A.Getstudent();
A.Showperson();
A.Showstudent();
return 0;

}

class teacher:public person
{
private:
char work;
char department;
public:
void Getteacher()
{
cout<<"请输入职称:";
cin>>work;
cout<<"请输入部门:";
cin>>department;
}
void Showteacher()
{
cout<<"职称:"<<work<<endl;
cout<<"部门:"<<department<<endl;
};
int main()
{
teacher B:
B.Getperson();
B.Getteacher();
B.Showperson();
B.Showteacher();
return 0;
}
展开
 我来答
game_toad
2010-05-11 · TA获得超过140个赞
知道答主
回答量:15
采纳率:0%
帮助的人:0
展开全部
首先有2个main()函数 这个可定错了,程序只可以有一个main()函数,它作为程序的入口。
所以你要去掉一个main();
另外少了一个}

#include<iostream>
using namespace std;

class person
{
private:
char name[20];
int number;
public:
void Getperson()
{
cout<<"请输入名字:";
cin>>name;
cout<<"请输入学号:";
cin>>number;
}
void Showperson()
{
cout<<"姓名:"<<name<<endl;
cout<<"学号:"<<number<<endl;
}
};

class student:public person
{
private:
float score;
char clas;
public:
void Getstudent()
{
cout<<"请输入成绩:";
cin>>score;
cout<<"请输入班级:";
cin>>clas;
}
void Showstudent()
{
cout<<"成绩:"<<score<<endl;
cout<<"班级:"<<clas<<endl;
}
};

int main()
{
student A;
A.Getperson();
A.Getstudent();
A.Showperson();
A.Showstudent();
return 0;
}

class teacher:public person
{
private:
char work;
char department;
public:
void Getteacher()
{
cout<<"请输入职称:";
cin>>work;
cout<<"请输入部门:";
cin>>department;
}
void Showteacher()
{
cout<<"职称:"<<work<<endl;
cout<<"部门:"<<department<<endl;
} //---------------------------缺个大括号
};

/*int main()
{
teacher B:
B.Getperson();
B.Getteacher();
B.Showperson();
B.Showteacher();
return 0;
} */
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式