I'm writing a game in c++ in microsoft visual studio 2010, yesterday I wrote a pong game and everything was fine but now the compiler telling me that there is a lot of errors for example:
1>w:\c++\planet escape\planet escape\room.h(25): error C2061: syntax error : identifier 'WorldMap'
And here is the Room.h file:
#pragma once
#include <allegro5/allegro.h>
#include <vector>
#include "Entity.h"
#include "WorldMap.h"
#include "Link.h"
#define ROOM_W 20
#define ROOM_H 20
class Room{
private:...
public:...
};
When in code there is no mistakes and it sees all the classes fine. So what can cause such mistake?
EDIT: here is the WorldMap.h
#pragma once
#include <allegro5/allegro.h>
#include "Room.h"
#include "Player.h"
#define WORLD_W 10
#define WORLD_H 10
class WorldMap{
private:...
public:...
};
If when I'm runing it he cant see it then why he see it when coding?
WorldMap.hdefinesWorldMaptype? compiler is telling you it cannot identify the typeWorldMap.WorldMap*you don't actually need to pull in the whole definition anyway - you can just add aclass WorldMap;before yourclass Room {..};declaration. You'll need the full class before you actually use it, though.WorldMap.hdoes not defineWorldMapthen OP might get rid of this error, but will be eventually stuck at a point where, forward declaration won't work.