VS2008 がこのコンパイル エラーをスローしている MSVC++ 2008 に問題があります。
error C2509: 'render' : member function not declared in 'PlayerSpriteKasua'
さて、私を混乱させているのは、 render() が定義されているが、継承されたクラスであるということです。
クラス定義は次のように機能します。
SpriteBase -Inherited By-> PlayerSpriteBase -Inherited By-> PlayerSpriteKasua
したがって、SpriteBase.h の簡素化されたバージョンは次のとおりです。
class SpriteBase {
public:
//Variables=============================================
-snip-
//Primary Functions=====================================
virtual void think()=0; //Called every frame to allow the sprite to process events and react to the player.
virtual void render(long long ScreenX, long long ScreenY)=0; //Called every frame to render the sprite.
//Various overridable and not service/event functions===
virtual void died(); //Called when the sprite is killed either externally or via SpriteBase::kill().
-snip-
//======================================================
};
PlayerSpriteBase.h は次のとおりです。
class PlayerSpriteBase : public SpriteBase
{
public:
virtual void pose() = 0;
virtual void knockback(bool Direction) = 0;
virtual int getHealth() = 0;
};
最後に、PlayerSpriteKasua.h は次のとおりです。
class PlayerSpriteKasua : public PlayerSpriteBase
{
public:
};
まだメンバーがいないことはわかっていますが、それは単純にメンバーを追加できなかったからです。PlayerSpriteBase についても同様です。それに入る他のものが残っています。
PlayerSpriteKasua.cpp のコードは次のとおりです。
#include "../../../MegaJul.h" //Include all the files needed in one go
void PlayerSpriteKasua::render(long long ScreenX, long long ScreenY) {
return;
}
void PlayerSpriteKasua::think() {
return;
}
int PlayerSpriteKasua::getHealth() {
return this->Health;
}
と入力するとvoid PlayerSpriteKasua::
、Intellisense は PlayerSpriteBase と SpriteBase のすべてのメンバーを一覧表示してポップアップしますが、コンパイル時に上記のように失敗します。
このエラーが発生する特定の理由はありますか?
PlayerSpriteBase.cpp は空で、まだ何も入っていません。
SpriteBase.cpp には SpriteBase の多くの関数定義があり、PlayerSpriteKasua.cpp と同じ形式を使用します。
void SpriteBase::died() {
return;
}
は一例です。