ベクトル宣言に問題があります。
std :: vectorを使用したリンクエラー
の.h
#ifndef ANIMATEDSPRITE_H_
#define ANIMATEDSPRITE_H_
#include "Sprite.h"
#include <vector>
//using namespace std;
class AnimatedSprite //abstract class to point sprites
{
public:
AnimatedSprite();
~AnimatedSprite();
//gets and sets
Sprite GetMySprite(int _index);
void SetSpriteToList(Sprite _sprite);
int GetState() const;
void SetState(int _state);
//other
private:
std::vector<Sprite> spriteList;
int state; //estado que esse sprite representa (parado esquerda, andando direita, etc)
};
#endif
た.cpp
#include "AnimatedSprite.h"
AnimatedSprite::AnimatedSprite()
{
spriteList.clear();
state = NULL;
}
AnimatedSprite::~AnimatedSprite()
{
}
Sprite AnimatedSprite::GetMySprite(int _index)
{
return spriteList[_index];
}
void AnimatedSprite::SetSpriteToList(Sprite _sprite)
{
//Sprite* temp = new Sprite(1,2);
spriteList.push_back(_sprite);
}
int AnimatedSprite::GetState() const
{
return state;
}
void AnimatedSprite::SetState(int _state)
{
state = _state;
}
しかし、私は2つのエラー取得しています:
ここでは、コードです
エラー1つのエラーはLNK2019 :未解決のex "public:class Sprite & __thiscall std :: vector :: :: operator [](unsigned int)"($ A @ $?@ VSprite @@ V?$ allocator @ VSprite @@)で使用される_CrtDbgReportWは、 @std @@@のstd @@ QAEAAVSprite @@ I @ Z)AnimatedSprite.obj
エラー2致命的なエラーLNK1120:1つの未解決の外部C:\ DevProjects \ SDLSkeletonデバッグ\ \ SDLSkeleton.exe
Iプリプロセッサの定義から_DEBUGを削除する解決策が見つかりましたが、それはちょっと間違っているようです。
正しい解決策ですか?それを取り除いた結果は何ですか?
私がチェックした本とドキュメントでは、これは単なる共通の変数宣言であるべきですが、このエラーが表示されました。
ありがとうございます。