#include
#include
class Students{
char name[80];
char sex[5],job[10];
int age;
public:
Students(char *p,char *q,char *r,int n)
{
strcpy(name,p);
strcpy(sex,p);
strcpy(job,r);
age=n;
}
void display1();
void display2();
};
void Students:: display1()
{
char message1;
cout<<"请输入您所要的信息:";
cin>>message1;
switch(message1)
{
case 'n':cout<
}
void Students:: display2()
{
cout<<"姓名:"<
class Messages:public Students
{
char school[20],major[10];
int grade;
public:
Messages(char *p,char *q,char *r,int n,char *s,char *t,int m):Students(p,q,r,n)
{
strcpy(school,s);
strcpy(major,t);
grade=m;
}
/* Messages(char *p,char *q,char *r,int n,char *s char *t,int m): Students(p,q,r,n)
{
strcpy(school,s);
strcpy(major,t);
grade=m;
}*/
void display3();
void display4();
};
/*构造函数出错,上面是我改正过的*/
void Messages::display3()
{
Students::display1();
char message2;
cout<<"请输入您所要的信息:";
cin>>message2;
switch(message2)
{
case 'x':cout<
}
void Messages::display4()
{
cout<<"学校:"<
void main()
{
Messages a("张三","男","学生",19,"**大学","专业",80);
a.display3();
a.display4();/*少了括号*/
}
/*最主要的错误是因为switch不能传字符串进行比较,只有字符和整形数据可以,现在已经调试通过,具体还有什么再问我,一起学习啊,呵呵*/
switch中的条件表达式只能为整型数据,或可转换成整型的数据。你可以cout<<"请选择:1.学校,2.专业,3.成绩";然后在case中写 1,2,3
switch语句括号里面一定要是int类型,用if else判断语句加上strcmp函数就行了