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;
} 展开
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;
} 展开
1个回答
展开全部
首先有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;
} */
所以你要去掉一个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;
} */
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询