저는 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
그리고 여기 내 통화 당입니다 : 지금 잠시 동안 찾고 있었어요 그리고 내가 '돈 너무 큰 것이어야
#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;
}
그것을 보아라. 당신이 Doodad.h
FishPlayer
를 사용하여 같은
#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;
};
나는 당신을 도울 것이다, 그러나 싱글턴? 그것은 정말로 "도움이되지"않을 것입니다. – Puppy
상속을 제거하면 컴파일되고 player.h가 포함됩니다. – chris
'Player.h'는'FishPlayer.h'를 포함합니까? –