Программы на C++. Форум разработчиков
Anonymous
Ошибка компилятора по неизвестным причинам (C++)
Сообщение
Anonymous » 22 ноя 2024, 23:58
При попытке компиляции я получаю ошибку компилятора (C2061) в MSVS C++ 2010 IDE. Я просто понятия не имею, почему это происходит, поскольку не вижу явной ошибки.
Код: Выделить всё
#pragma once
#ifndef _CCOMPONENT_H
#define _CCOMPONENT_H
#include "CGame.h"
class CComponent
{
public:
CComponent(CGame &game);
~CComponent();
protected:
virtual void Draw();
virtual void Update();
virtual void Init();
void Dispose();
};
#endif // _CCOMPONENT_H
Ошибка компилятора:
Код: Выделить всё
ccomponent.h(10): error C2061: syntax error : identifier 'CGame'
Содержимое CGame.h
Код: Выделить всё
/**************************************************
*
*
****************************************************/
#pragma once
#ifndef _CGAME_H
#define _CGAME_H
#include
#include
//#include
#include
#include "SharedDef.h"
#include "CComponent.h"
#include "CTestPlayer.h"
using namespace std;
class CComponent;
class CTestPlayer;
const int MAX_COMPONENTS = 255;
class CGame
{
public:
// CONSTRUCTORS
CGame();
~CGame();
// ACCESSORS
ALLEGRO_DISPLAY *GetGameDisplay();
ALLEGRO_EVENT_QUEUE *GetGameEventQueue();
list GetComponents() { return *m_Components; }
void AddComponent(CComponent component);
bool IsRun();
void StartTimer();
void StopTimer();
virtual bool ShouldDraw();
virtual bool ShouldUpdate();
virtual void Update(void);
virtual void Draw(void);
virtual void Dispose();
protected:
virtual void RegisterEventSources();
virtual void Initialize();
private:
bool InitializeAllegro();
private:
ALLEGRO_DISPLAY *m_Display;
ALLEGRO_EVENT_QUEUE *m_EventQueue;
ALLEGRO_TIMER *m_Timer;
ALLEGRO_EVENT m_Event;
list *m_Components;
//CComponent *m_Components[MAX_COMPONENTS];
bool m_bIsRunning;
bool m_bShouldDraw;
};
#endif // _CGAME_H
и «класс CGame» объявлен и определен в «CGame.h», поэтому я действительно не понимаю, почему....
Подробнее здесь:
https://stackoverflow.com/questions/592 ... -reasons-c
1732309120
Anonymous
При попытке компиляции я получаю ошибку компилятора (C2061) в MSVS C++ 2010 IDE. Я просто понятия не имею, почему это происходит, поскольку не вижу явной ошибки. [code]#pragma once #ifndef _CCOMPONENT_H #define _CCOMPONENT_H #include "CGame.h" class CComponent { public: CComponent(CGame &game); ~CComponent(); protected: virtual void Draw(); virtual void Update(); virtual void Init(); void Dispose(); }; #endif // _CCOMPONENT_H [/code] [b]Ошибка компилятора:[/b] [code] ccomponent.h(10): error C2061: syntax error : identifier 'CGame' [/code] Содержимое CGame.h [code]/************************************************** * * ****************************************************/ #pragma once #ifndef _CGAME_H #define _CGAME_H #include #include //#include #include #include "SharedDef.h" #include "CComponent.h" #include "CTestPlayer.h" using namespace std; class CComponent; class CTestPlayer; const int MAX_COMPONENTS = 255; class CGame { public: // CONSTRUCTORS CGame(); ~CGame(); // ACCESSORS ALLEGRO_DISPLAY *GetGameDisplay(); ALLEGRO_EVENT_QUEUE *GetGameEventQueue(); list GetComponents() { return *m_Components; } void AddComponent(CComponent component); bool IsRun(); void StartTimer(); void StopTimer(); virtual bool ShouldDraw(); virtual bool ShouldUpdate(); virtual void Update(void); virtual void Draw(void); virtual void Dispose(); protected: virtual void RegisterEventSources(); virtual void Initialize(); private: bool InitializeAllegro(); private: ALLEGRO_DISPLAY *m_Display; ALLEGRO_EVENT_QUEUE *m_EventQueue; ALLEGRO_TIMER *m_Timer; ALLEGRO_EVENT m_Event; list *m_Components; //CComponent *m_Components[MAX_COMPONENTS]; bool m_bIsRunning; bool m_bShouldDraw; }; #endif // _CGAME_H [/code] и «класс CGame» объявлен и определен в «CGame.h», поэтому я действительно не понимаю, почему.... Подробнее здесь: [url]https://stackoverflow.com/questions/5920585/compiler-error-for-unknown-reasons-c[/url]