gpt4 book ai didi

c++ - 错误 LNK2019 : unresolved external symbol "public: __thiscall user::user(void)" (? ?0user@@QAE@XZ) 在函数 "..."中引用

转载 作者:搜寻专家 更新时间:2023-10-31 00:00:00 24 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
What is an undefined reference/unresolved external symbol error and how do I fix it?

我正在尝试编写大学作业的代码,但似乎在编译时遇到问题,我已经对错误进行了 Google 搜索,我看到的修复不适用于我的代码。非常感谢您的帮助。

错误代码如下:

Error 1 error LNK2019: unresolved external symbol "public: __thiscall user::user(void)" (??0user@@QAE@XZ) 
referenced in function "void __cdecl `dynamic initializer for 'player''(void)" (??__Eplayer@@YAXXZ)
C:\Users\obinyans\Documents\Visual Studio 2010\Projects\test\test\Challenge 1.obj

下面是我的代码的拷贝:

#include <iostream>
#include <string>
#include <math.h>

using namespace std;

void storeinfo() ;
void showinfo() ;


class user
{
string firstname, lastname, currentteam, position, status ;
int age ;
public:
user();
user(string, string, string, string, string, int) ;
void setFirstName(string fname)
{firstname = fname;}
void setLastName(string lname)
{lastname = lname;}
void setCurrentTeam(string cteam)
{currentteam = cteam;}
void setPosition(string pos)
{position = pos;}
void setStatus(string stat)
{status = stat;}
void setAge(int _age)
{age = _age;}

string getFirstName()
{return firstname ;}
string getLastName()
{return lastname ;}
string getCurrentTeam()
{return currentteam ;}
string getPosition()
{return position ;}
string getStatus()
{return status ;}
int getAge()
{return age ;}
};

user player[20] ;

int main()
{
;

int menu ;

cout << "MENU" << "\n" ;
cout << "\n 1. Store Player Information" ;
cout << "\n 2. Show Player Informaton" ;
cout << "\n 0. Exit" ;


cin >> menu ;
if (menu = 1)
{
storeinfo() ;
}
else if (menu = 2)
{
showinfo() ;
}
else if (menu = 0)
{
return 0;
}


cin.get() ;
return 0 ;

}

void storeinfo()
{
string firstname ;
string lastname ;
string currentteam ;
string position;
string status ;
int age ;

for (int i=0; i < 3; i++)
{
cout << "Enter First Name : " ; cin >> firstname ;
player[i].setFirstName(firstname) ;
cout << "Enter Last Name : " ; cin >> lastname ;
player[i].setLastName(lastname) ;
cout << "Enter Player's Age : " ;cin >> age;
player[i].setAge(age) ;
cout << "Enter Current Team : " ; cin >> currentteam ;
player[i].setCurrentTeam(currentteam) ;
cout << "Enter Position : " ; cin >> position ;
player[i].setPosition(position) ;
cout << "Enter Status : " ; cin >> status ;
player[i].setStatus(status) ;
}
}

void showinfo()
{
for (int i=0; i < 3; i++)
{
cout << "First Name : " << player[i].getFirstName() << " " << "Last Name : " << player[i].getLastName() <<
" " << "Age : " << player[i].getAge() << " " << "Current Team : " << player[i].getCurrentTeam() <<
" " << "Position : " << player[i].getPosition() << " " << "Status : " << player[i].getStatus() ;
}
}

感谢您的帮助。

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com