0

私は C++ クラスを持っており、大騒ぎせずにコンパイルされる同様の構文で書かれた別のクラスがありますが、このエラーが発生し続けます。

これが私の.hです:

#ifndef FISHPLAYER_H
#define FISHPLAYER_H

#include "Player.h"


class FishPlayer : public Player
{
public:
    float xThrust;
    float yThrust;
    static FishPlayer* getInstance();
protected:
private:
    FishPlayer();
    ~FishPlayer();
    static FishPlayer* instance;
};

#endif

そして、ここに私の .cpp があります:

#include "..\include\FishPlayer.h"

FishPlayer* FishPlayer::instance=0;  // <== I Get The Error Here

FishPlayer::FishPlayer()
{
    //ctor
    xThrust = 15.0f;
    yThrust = 6.0f;
}

FishPlayer::~FishPlayer()
{
    //dtor
}


FishPlayer* FishPlayer::getInstance() { // <== I Get The Error Here
    if(!instance) {
        instance = new FishPlayer();
    }
    return instance;
}

しばらく探していたのですが、見えないほど大きなものに違いありません。

継承は次のとおりです。

#ifndef PLAYER_H
#define PLAYER_H
#include "Ennemy.h"

class Player : public Ennemy
{
    public:
    protected:
        Player();
        ~Player();
    private:
};

#endif // PLAYER_H

そしてより高いもの:

#ifndef ENNEMY_H
#define ENNEMY_H

#include "Doodad.h"

class Ennemy : public Doodad
{
    public:
        float speedX;
        float maxSpeedX;
        float speedY;
        float maxSpeedY;
        float accelerationX;
        float accelerationY;
        Ennemy();
        ~Ennemy();
    protected:
    private:
};

そしてスーパークラス

#include <vector>
#include <string>


enum DoodadType{FishPlayer,Player,AstroPlayer,Ennemy,DoodadT = 999};
enum DoodadRange{Close, Medium , Far};
enum EvolutionStage{Tiny, Small, Average, Large};

class Doodad
{
    public:
        float score;
        void die();
        EvolutionStage evolutionStage;
        DoodadRange range;
        Doodad();
        virtual ~Doodad();
        Doodad(Doodad const& source);
        std::vector<Animation> animations;
        double posX;
        double posY;
        std::string name;
        std::string currentAnimation;
        int currentFrame;
        DoodadType type();
        SDL_Surface getSpriteSheet();
        bool moving;
        void update();
    protected:
    private:
        SDL_Surface spriteSheet;
};
4

1 に答える 1

5

FishPlayerで列挙値として使用しているようですDoodad.h

宣言しようとしているクラスと同じ名前です。それが問題の原因かもしれません。

一般に、このような衝突を避けるために、enum 値にFISH_PLAYER、またはType_FishPlayer一種の命名スキームを使用することをお勧めします。

于 2012-12-17T21:26:09.907 に答える