C++上机实验时出现 mismatch in formal parameter list 的错误是为什么啊 ???求解!!谢谢了
以下是程序:#include<iostream>#include<string>usingnamespacestd;classStudent{public:voidget...
以下是程序:
#include<iostream>
#include<string>
using namespace std;
class Student
{public:
void get_value();
void display();
protected:
int num;
char name[20];
char sex;
};
void Student::get_value()
{cin>>num>>name>>sex;}
void Student::display()
{cout<<"num:"<<num<<endl;
cout<<"name:"<name<<endl;
cout<<"sex:"<<sex<<endl;}
class Student1:protected Student
{public:
void get_value_1();
void display1();
private:
int age;
char addr[30];
};
void Student1::get_value_1()
{get_value();
cin>>age>>addr;
}
void Student1::display1()
{cout<<"num:"<<num<<endl;
cout<<"name:"<<name<<endl;
cout<<"sex:"<<sex<<endl;
cout<<"age:"<<age<<endl;
cout<<"address:"<<addr<<endl;
}
int main()
{Student1 stud1;
stud1.get_value_1();
stud1.dispaly1();
//stud1.num=10023;
return 0;} 展开
#include<iostream>
#include<string>
using namespace std;
class Student
{public:
void get_value();
void display();
protected:
int num;
char name[20];
char sex;
};
void Student::get_value()
{cin>>num>>name>>sex;}
void Student::display()
{cout<<"num:"<<num<<endl;
cout<<"name:"<name<<endl;
cout<<"sex:"<<sex<<endl;}
class Student1:protected Student
{public:
void get_value_1();
void display1();
private:
int age;
char addr[30];
};
void Student1::get_value_1()
{get_value();
cin>>age>>addr;
}
void Student1::display1()
{cout<<"num:"<<num<<endl;
cout<<"name:"<<name<<endl;
cout<<"sex:"<<sex<<endl;
cout<<"age:"<<age<<endl;
cout<<"address:"<<addr<<endl;
}
int main()
{Student1 stud1;
stud1.get_value_1();
stud1.dispaly1();
//stud1.num=10023;
return 0;} 展开
1个回答
展开全部
这样写就行了。
#include<iostream>
#include<string>
using namespace std;
class Student
{
public:
void get_value();
void display();
protected:
int num;
string name;
char sex;
};
void Student::get_value()
{cin>>num>>name>>sex;}
void Student::display()
{cout<<"num:"<<num<<endl;
cout<<"name:"<<name<<endl;
cout<<"sex:"<<sex<<endl;}
class Student1:protected Student
{public:
void get_value_1();
void display1();
private:
int age;
string addr;
};
void Student1::get_value_1()
{get_value();
cin>>age>>addr;
}
void Student1::display1()
{cout<<"num:"<<num<<endl;
cout<<"name:"<<name<<endl;
cout<<"sex:"<<sex<<endl;
cout<<"age:"<<age<<endl;
cout<<"address:"<<addr<<endl;
}
int main()
{Student1 stud1;
stud1.get_value_1();
stud1.display1();
//stud1.num=10023;
return 0;}
第十八行少一个<符号。
cout<<"name:"<name<<endl;
#include<iostream>
#include<string>
using namespace std;
class Student
{
public:
void get_value();
void display();
protected:
int num;
string name;
char sex;
};
void Student::get_value()
{cin>>num>>name>>sex;}
void Student::display()
{cout<<"num:"<<num<<endl;
cout<<"name:"<<name<<endl;
cout<<"sex:"<<sex<<endl;}
class Student1:protected Student
{public:
void get_value_1();
void display1();
private:
int age;
string addr;
};
void Student1::get_value_1()
{get_value();
cin>>age>>addr;
}
void Student1::display1()
{cout<<"num:"<<num<<endl;
cout<<"name:"<<name<<endl;
cout<<"sex:"<<sex<<endl;
cout<<"age:"<<age<<endl;
cout<<"address:"<<addr<<endl;
}
int main()
{Student1 stud1;
stud1.get_value_1();
stud1.display1();
//stud1.num=10023;
return 0;}
第十八行少一个<符号。
cout<<"name:"<name<<endl;
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询