私はPlayerクラスを含む単純なゲームを作成しており、インスタンス化されたときにプレーヤーを保持するための配列を作成しました。問題は、プログラムを実行するたびに、LNK2019エラー(「未解決の外部シンボル」)が発生することです。なぜこれが起こっているのか、それを正しく機能させる方法がわかりません。どんな助けでも大歓迎です。
Player *player = new Player[9];
for(int i = 0; i< world1.numPlayers;i++) // ADD PLAYERS TO ARRAY
{
Player tempplayer(3,3,5,1);
player[i] = tempplayer;
}
これはプレーヤークラスの定義です。
#pragma once
class Player
{
public:
Player(int width, int height, int xPos, int health );
~Player(void);
Player();
int getWidth();
int getHeight();
int getHealth();
int getPos();
void setHealth(int newHealth);
bool isAlive();
int width;
int height;
int health;
int xPos;
};
正確な警告は次のとおりです。「エラー1エラーLNK2019:未解決の外部シンボル "public:__thiscall Player :: Player(void)"(?? 0Player @@ QAE @ XZ)関数_main C:\ Users \ Alex \ Documents \ Visual Studio 2012 \ Projects \ ConsoleApplication2 \ ConsoleApplication2 \ World.obj ConsoleApplicati on2 "