c++/作业.obj : error LNK2019: 无法解析的外部符号
#include<iostream>usingnamespacestd;classStu;classPeo{intage;intpassword;intsex;publi...
#include<iostream>
using namespace std;
class Stu;
class Peo{
int age;
int password;
int sex;
public:
char *name;
Peo(int age,int passwod,int sex,char * name);
int p1(){return password;}
};
class Teacher:public Peo{
char* classes;
public :
Teacher(int age,int password,int sex,char* name,char* classes):Peo(age, password, sex,name)
{this->classes=classes;}
void inputscore(Stu & );
};
class Stu: public Peo{
char* major;
float score;
public:
Stu(int age,int password,int sex,char* name ,char* major):Peo(age, password, sex,name)
{
this->major=major;
}
friend void Teacher::inputscore( Stu &);
void checkscore(){
int a;
cout<<"enter password"<<endl;
cin>>a;
if(p1()==a){
cout<<name<<endl<<score<<endl;
}
else
cout<<"password wrong";
}
};
void Teacher ::inputscore(Stu & stu )
{
int a;
cout<<"please enter password";cin>>a;
if(p1()==a)
{cout<<"score=?";
cin>>stu.score;}
else
cout<<"password error";
}
int main()
{Stu s1(20,123456,0,"jack","math");
s1.checkscore();
Teacher t1(25,654123,1,"marry","642");
t1.inputscore(s1);
system("pause");
return 0;
}
-------------------
作业.obj : error LNK2019: 无法解析的外部符号 "public: __thiscall Peo::Peo(int,int,int,char *)" (??0Peo@@QAE@HHHPAD@Z),该符号在函数 "public: __thiscall Teacher::Teacher(int,int,int,char *,char *)" (??0Teacher@@QAE@HHHPAD0@Z) 中被引用
1>c:\users\dingyinghua\documents\visual studio 2010\Projects\22\Debug\22.exe : fatal error LNK1120: 1 个无法解析的外部命令 展开
using namespace std;
class Stu;
class Peo{
int age;
int password;
int sex;
public:
char *name;
Peo(int age,int passwod,int sex,char * name);
int p1(){return password;}
};
class Teacher:public Peo{
char* classes;
public :
Teacher(int age,int password,int sex,char* name,char* classes):Peo(age, password, sex,name)
{this->classes=classes;}
void inputscore(Stu & );
};
class Stu: public Peo{
char* major;
float score;
public:
Stu(int age,int password,int sex,char* name ,char* major):Peo(age, password, sex,name)
{
this->major=major;
}
friend void Teacher::inputscore( Stu &);
void checkscore(){
int a;
cout<<"enter password"<<endl;
cin>>a;
if(p1()==a){
cout<<name<<endl<<score<<endl;
}
else
cout<<"password wrong";
}
};
void Teacher ::inputscore(Stu & stu )
{
int a;
cout<<"please enter password";cin>>a;
if(p1()==a)
{cout<<"score=?";
cin>>stu.score;}
else
cout<<"password error";
}
int main()
{Stu s1(20,123456,0,"jack","math");
s1.checkscore();
Teacher t1(25,654123,1,"marry","642");
t1.inputscore(s1);
system("pause");
return 0;
}
-------------------
作业.obj : error LNK2019: 无法解析的外部符号 "public: __thiscall Peo::Peo(int,int,int,char *)" (??0Peo@@QAE@HHHPAD@Z),该符号在函数 "public: __thiscall Teacher::Teacher(int,int,int,char *,char *)" (??0Teacher@@QAE@HHHPAD0@Z) 中被引用
1>c:\users\dingyinghua\documents\visual studio 2010\Projects\22\Debug\22.exe : fatal error LNK1120: 1 个无法解析的外部命令 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询