C++“error LNK2019: 无法解析的外部符号”错误,怎么修改?
usingnamespacestd;classDate{public:Date(int,int,int);voidshowDate(){cout<<year<<"/"<<...
using namespace std;
class Date
{
public:
Date(int,int,int);
void showDate(){
cout<<year<<"/"<<month<<"/"<<day<<endl;
}
void showDate() const{
cout<<year<<"/"<<month<<"/"<<day<<endl;
}
int Year(){
return year;
}
int Month(){
return month;
}
int Day(){
return day;
}
void Getdate(int y,int m,int d){
year = y;
month = m;
day = d;
}
private:
int year,month,day;
};
Date::Date(int y=0,int m=0,int d=0):year(y),month(m),day(d){}
class Person
{
public:
Person();
Person(int n,char s,char i[19],Date birthday):birthday(birthday) {
number=n; sex=s; strcpy(*id,i);
}
Person(const Person &p);
void showMessage();
void showMessage()const;
void Getperson(int n,char s,char i[19],Date d1);
~Person(){
cout<<"已成功录入人员信息,完成输入临时数据的清除。"<<endl;
}
private:
int number;
char sex;
char *id[19];
Date birthday;
};
void Person::Getperson(int n,char s,char i[19],Date d1){
birthday.Getdate(d1.Year(),d1.Month(),d1.Day());
number = n;
sex = s;
strcpy(*id,i);
}
Person::Person(const Person &p):birthday(p.birthday){
number = p.number;
sex = p.sex;
strcpy(*id,*p.id);
}
void Person::showMessage()
{
cout<<"这位人员的信息为:"<<endl;
cout<<"编号:"<<number<<endl;
cout<<"性别:"<<sex<<endl;
cout<<"出生日期:";
birthday.showDate();
cout<<"身份证号:"<<*id<<endl;
cout<<endl;
}
void Person::showMessage()const
{
cout<<"这位人员的信息为:"<<endl;
cout<<"编号:"<<number<<endl;
cout<<"性别:"<<sex<<endl;
cout<<"出生日期:";
birthday.showDate();
cout<<"身份证号:"<<*id<<endl;
cout<<endl;
}
void main()
{
int y,m,d;
int number;
int *num=&number;
char sex;
char *id[19]={0};
Person p1[2];
for(int a=0;a<2;a++)
{
cout<<"开始录入信息"<<endl;
cout<<"请输入编号:";
cin>>number;
cout<<"请输入性别(Male:m/Female:f):";
cin>>sex;
cout<<"请输入身份证号:";
cin>>*id;
cout<<"请输入出生日期(年/月/日):";
cin>>y>>m>>d;
Date d1(y,m,d);
cout<<endl;
p1[a].Getperson(number,sex,*id,d1);
const Person p2=p1[a];
p2.showMessage();
}
}
obj : error LNK2019: 无法解析的外部符号 "public: __thiscall Person::Person(void)" (??0Person@@QAE@XZ),该符号在函数 _main 中被引用
Debug\lab.exe : fatal error LNK1120: 1 个无法解析的外部命令
求解决!!!! 展开
class Date
{
public:
Date(int,int,int);
void showDate(){
cout<<year<<"/"<<month<<"/"<<day<<endl;
}
void showDate() const{
cout<<year<<"/"<<month<<"/"<<day<<endl;
}
int Year(){
return year;
}
int Month(){
return month;
}
int Day(){
return day;
}
void Getdate(int y,int m,int d){
year = y;
month = m;
day = d;
}
private:
int year,month,day;
};
Date::Date(int y=0,int m=0,int d=0):year(y),month(m),day(d){}
class Person
{
public:
Person();
Person(int n,char s,char i[19],Date birthday):birthday(birthday) {
number=n; sex=s; strcpy(*id,i);
}
Person(const Person &p);
void showMessage();
void showMessage()const;
void Getperson(int n,char s,char i[19],Date d1);
~Person(){
cout<<"已成功录入人员信息,完成输入临时数据的清除。"<<endl;
}
private:
int number;
char sex;
char *id[19];
Date birthday;
};
void Person::Getperson(int n,char s,char i[19],Date d1){
birthday.Getdate(d1.Year(),d1.Month(),d1.Day());
number = n;
sex = s;
strcpy(*id,i);
}
Person::Person(const Person &p):birthday(p.birthday){
number = p.number;
sex = p.sex;
strcpy(*id,*p.id);
}
void Person::showMessage()
{
cout<<"这位人员的信息为:"<<endl;
cout<<"编号:"<<number<<endl;
cout<<"性别:"<<sex<<endl;
cout<<"出生日期:";
birthday.showDate();
cout<<"身份证号:"<<*id<<endl;
cout<<endl;
}
void Person::showMessage()const
{
cout<<"这位人员的信息为:"<<endl;
cout<<"编号:"<<number<<endl;
cout<<"性别:"<<sex<<endl;
cout<<"出生日期:";
birthday.showDate();
cout<<"身份证号:"<<*id<<endl;
cout<<endl;
}
void main()
{
int y,m,d;
int number;
int *num=&number;
char sex;
char *id[19]={0};
Person p1[2];
for(int a=0;a<2;a++)
{
cout<<"开始录入信息"<<endl;
cout<<"请输入编号:";
cin>>number;
cout<<"请输入性别(Male:m/Female:f):";
cin>>sex;
cout<<"请输入身份证号:";
cin>>*id;
cout<<"请输入出生日期(年/月/日):";
cin>>y>>m>>d;
Date d1(y,m,d);
cout<<endl;
p1[a].Getperson(number,sex,*id,d1);
const Person p2=p1[a];
p2.showMessage();
}
}
obj : error LNK2019: 无法解析的外部符号 "public: __thiscall Person::Person(void)" (??0Person@@QAE@XZ),该符号在函数 _main 中被引用
Debug\lab.exe : fatal error LNK1120: 1 个无法解析的外部命令
求解决!!!! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询