プログラムをコンパイルしようとすると、以下のエラーが発生しますが、「LittleMonkey」クラス宣言を含むヘッダーを含めました。
1>------ Build started: Project: Estrellas, Configuration: Debug x64 ------
1>Build started 17/08/2013 0:24:31.
1>InitializeBuildStatus:
1> Touching "x64\Debug\Estrellas.unsuccessfulbuild".
1>ClCompile:
1> Missile_mgr.cpp
1>Missile_mgr.cpp(68): error C2146: syntax error : missing ';' before identifier 'monkey'
1>Missile_mgr.cpp(68): error C3861: 'monkey': identifier not found
1>Missile_mgr.cpp(79): warning C4482: nonstandard extension used: enum 'MissileEventType' used in qualified name
1>Missile_mgr.cpp(99): warning C4482: nonstandard extension used: enum 'MissileEventType' used in qualified name
1>Missile_mgr.cpp(106): warning C4482: nonstandard extension used: enum 'MissileEventType' used in qualified name
1>Missile_mgr.cpp(113): warning C4482: nonstandard extension used: enum 'MissileEventType' used in qualified name
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:03.21
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
これらの 2 つのファイルで何か問題がありましたか?
Missile_mgr.cpp:
#include "Missile_mgr.h"
#include "Constants.h"
#include "Game.h"
#include "Missile.h"
void Missile_mgr::Test() {
LittleMonkey monkey(pGame);
}
Missile.h、LittleMonkey を含む
#ifndef MISSILE_H
#define MISSILE_H
#include "Object.h"
#include "AnimatedSprite.h"
class Game;
class Missile : public Object {
public:
AnimatedSprite aSp;
Missile(Game* _pGame);
virtual void Load()=0;
virtual void Update()=0;
void Draw();
Game* pGame;
};
class LittleMonkey : public Missile {
public:
explicit LittleMonkey(Game* _pGame) : Missile(_pGame) { };
virtual void Load();
virtual void Update();
};
#endif
Missile_mgr.h
#ifndef MISSILE_MGR_H
#define MISSILE_MGR_H
#include "Quadtree.h"
#include "Missile.h"
class Game;
enum MissileEventType { Wave, WaitForClean, WaitTime, Boss };
struct MissileEvent {
MissileEventType eventType;
union {
int WaitTime;
} aditional;
};
class Missile_mgr {
public:
enum MissileType { LittleMonkey, Calamar };
bool initialize(Game* _pGame);
void LoadLevel(int level);
void Update(); // Update() calls HandleEvents()
void Draw();
void Clear();
std::list<Missile*> missileList;
sf::Texture txLittleMonkey;
sf::Texture txBigMonkey;
sf::Texture txCalamar;
sf::Texture txFruits;
sf::Texture txRockets;
sf::Texture txStars;
// Do waves?
float wait;// this is for wait event.
bool waiting;
Game* pGame;
private:
bool HandleEvents();
void DoWave();
void DoBoss();
std::vector<MissileEvent> eventQueue;
void AddMissile(MissileType* type);
};
#endif