求求求求求求求求求!!!哪错了 C++++++++++++++++ 5
#include<iostream>#include<cstring>usingnamespacestd;classpeople{longintID;charName[1...
# include<iostream>
# include<cstring>
using namespace std;
class people{
long int ID;
char Name[10],Sex[4],Bir[10],Home[10];
public:
void setI(int i);
void setN(char Name[]);
void setS(char Sex[]);
void setB(char Bir[]);
void setH(char Home[]);
int getID();
char*getN();
char*getS();
char*getB();
char*getH();
};
void people::setI(int i){
ID=i;
}
void people::setN(char Name[]){
strcpy(Name,name);
}
void people::setS(char Sex[]){
strcpy(Sex,sex);
}
void people::setB(char Bir[]){
strcpy(Bir,bir);
}
void people::setH(char Home[]){
strcpy(Home,home);
}
int people::getID(){
return ID;
}
char*people::getN(){
return Name;
}
char*people::getS(){
return Sex;
}
char*people::getB(){
return Bir;
}
char*people::getH(){
return Home;
}
void main(){
people a;
a.setID(4211251993081313);
char string[21]={'\0'};
a.setN("沙壁");
a.setS("男");
a.setB("2月30日");
a.setH("湖北公安");
cout<<"ID"<<a.getID()<<endl;
cout<<"name"<<a.getN()<<endl;
cout<<"sex"<<a.getS()<<endl;
cout<<"bir"<<a.getB()<<endl;
cout<<"home"<<a.getH()<<endl;
}
\65564646456464544444444444444444444444\3.cpp(23) : error C2065: 'name' : undeclared identifier
E:\65564646456464544444444444444444444444\3.cpp(26) : error C2065: 'sex' : undeclared identifier
E:\65564646456464544444444444444444444444\3.cpp(29) : error C2065: 'bir' : undeclared identifier
E:\65564646456464544444444444444444444444\3.cpp(32) : error C2065: 'home' : undeclared identifier
E:\65564646456464544444444444444444444444\3.cpp(51) : error C2039: 'setID' : is not a member of 'people'
E:\65564646456464544444444444444444444444\3.cpp(4) : see declaration of 'people'
执行 cl.exe 时出错.
3.obj - 1 error(s), 0 warning(s) 展开
# include<cstring>
using namespace std;
class people{
long int ID;
char Name[10],Sex[4],Bir[10],Home[10];
public:
void setI(int i);
void setN(char Name[]);
void setS(char Sex[]);
void setB(char Bir[]);
void setH(char Home[]);
int getID();
char*getN();
char*getS();
char*getB();
char*getH();
};
void people::setI(int i){
ID=i;
}
void people::setN(char Name[]){
strcpy(Name,name);
}
void people::setS(char Sex[]){
strcpy(Sex,sex);
}
void people::setB(char Bir[]){
strcpy(Bir,bir);
}
void people::setH(char Home[]){
strcpy(Home,home);
}
int people::getID(){
return ID;
}
char*people::getN(){
return Name;
}
char*people::getS(){
return Sex;
}
char*people::getB(){
return Bir;
}
char*people::getH(){
return Home;
}
void main(){
people a;
a.setID(4211251993081313);
char string[21]={'\0'};
a.setN("沙壁");
a.setS("男");
a.setB("2月30日");
a.setH("湖北公安");
cout<<"ID"<<a.getID()<<endl;
cout<<"name"<<a.getN()<<endl;
cout<<"sex"<<a.getS()<<endl;
cout<<"bir"<<a.getB()<<endl;
cout<<"home"<<a.getH()<<endl;
}
\65564646456464544444444444444444444444\3.cpp(23) : error C2065: 'name' : undeclared identifier
E:\65564646456464544444444444444444444444\3.cpp(26) : error C2065: 'sex' : undeclared identifier
E:\65564646456464544444444444444444444444\3.cpp(29) : error C2065: 'bir' : undeclared identifier
E:\65564646456464544444444444444444444444\3.cpp(32) : error C2065: 'home' : undeclared identifier
E:\65564646456464544444444444444444444444\3.cpp(51) : error C2039: 'setID' : is not a member of 'people'
E:\65564646456464544444444444444444444444\3.cpp(4) : see declaration of 'people'
执行 cl.exe 时出错.
3.obj - 1 error(s), 0 warning(s) 展开
3个回答
展开全部
void people::setN(char Name[]){
strcpy(Name,name);
}
参数不要与成员同名。所以你应该是写反了。
void people::setN(char name[]){
strcpy(Name,name);
}
error C2039:: is not a member of 'people'
这个错误很 明显, 你定义类的时候是写的void setI(int i);
调用的时候多了一个"D".
strcpy(Name,name);
}
参数不要与成员同名。所以你应该是写反了。
void people::setN(char name[]){
strcpy(Name,name);
}
error C2039:: is not a member of 'people'
这个错误很 明显, 你定义类的时候是写的void setI(int i);
调用的时候多了一个"D".
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
# include<iostream>
# include<cstring>
using namespace std;
class people{
long int ID;
char Name[10],Sex[4],Bir[10],Home[10];
public:
void setID(int i);
void setN(char Name[]);
void setS(char Sex[]);
void setB(char Bir[]);
void setH(char Home[]);
int getID();
char*getN();
char*getS();
char*getB();
char*getH();
};
void people::setID(int i){
ID=i;
}
void people::setN(char Name[]){
char *name;
strcpy(Name,name);
}
void people::setS(char Sex[]){
char *sex;
strcpy(Sex,sex);
}
void people::setB(char Bir[]){
char *bir;
strcpy(Bir,bir);
}
void people::setH(char Home[]){
char *home;
strcpy(Home,home);
}
int people::getID(){
return ID;
}
char*people::getN(){
return Name;
}
char*people::getS(){
return Sex;
}
char*people::getB(){
return Bir;
}
char*people::getH(){
return Home;
}
void main(){
people a;
a.setID(4211251993081313);
char string[21]={'\0'};
a.setN("沙壁");
a.setS("男");
a.setB("2月30日");
a.setH("湖北公安");
cout<<"ID"<<a.getID()<<endl;
cout<<"name"<<a.getN()<<endl;
cout<<"sex"<<a.getS()<<endl;
cout<<"bir"<<a.getB()<<endl;
cout<<"home"<<a.getH()<<endl;
}
# include<cstring>
using namespace std;
class people{
long int ID;
char Name[10],Sex[4],Bir[10],Home[10];
public:
void setID(int i);
void setN(char Name[]);
void setS(char Sex[]);
void setB(char Bir[]);
void setH(char Home[]);
int getID();
char*getN();
char*getS();
char*getB();
char*getH();
};
void people::setID(int i){
ID=i;
}
void people::setN(char Name[]){
char *name;
strcpy(Name,name);
}
void people::setS(char Sex[]){
char *sex;
strcpy(Sex,sex);
}
void people::setB(char Bir[]){
char *bir;
strcpy(Bir,bir);
}
void people::setH(char Home[]){
char *home;
strcpy(Home,home);
}
int people::getID(){
return ID;
}
char*people::getN(){
return Name;
}
char*people::getS(){
return Sex;
}
char*people::getB(){
return Bir;
}
char*people::getH(){
return Home;
}
void main(){
people a;
a.setID(4211251993081313);
char string[21]={'\0'};
a.setN("沙壁");
a.setS("男");
a.setB("2月30日");
a.setH("湖北公安");
cout<<"ID"<<a.getID()<<endl;
cout<<"name"<<a.getN()<<endl;
cout<<"sex"<<a.getS()<<endl;
cout<<"bir"<<a.getB()<<endl;
cout<<"home"<<a.getH()<<endl;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
额 滴个神呐 这是什么 我受到了惊吓!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询