Jump to content
  • Advertisement
Sign in to follow this  

C++ class not being recognised

This topic is 4024 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In my map.h
#ifndef __MAPS_H__
#define __MAPS_H__
#include "tile.h"
#include <vector>

class Map

	void FreeResources();
	void SetGeneric(); //setup a generic map
	void Draw();
	char *GetName()   {return _filename;}
	void Load(const char *file);
	void PlaceTile(Tile *tile, int type, int x, int y);
	void DeleteTile(int type, int x, int y);
	void SetDraw(bool draw);

	char _filename[STRING_SIZE];
	bool _draw;
	bool _drawGUI;
	std::vector<Tile> _tiles;

extern Map g_Map;


Tile is not being recognised by the compiler. tile.h
#ifndef __TILE_H__
#define __TILE_H__
#include "main.h"

enum TileType
	PATH = 0,
	WALL = 1

class Tile

	void SetBitmap(HBITMAP pic)		{_image = pic;}
	void SetFileName(char *name)	{strcpy(_filename, name);}
	void SetType(char type)			{_type = type;} 
	void SetCoords(int x, int y)	{_coords.x = x; _coords.y = y;}
	void SetIndex(int x, int y)		{_index.x = x; _index.y = y;}

	HBITMAP GetBitmap()		{return _image;}
	char *GetFileName()		{return _filename;}
	char  GetType()			{return _type;}
	POINT GetCoords()		{return _coords;}
	POINT GetIndex()		{return _index;}

	bool Solid()			{ return _solid;}

	// The set function for the tile class
	void SetSolid(bool value)		{_solid = value;}

	HBITMAP _image;
	char    _filename[STRING_SIZE];//image to load
	char	_type;
	POINT   _coords;
	POINT	_index;
	bool	_solid; //wall?


I cannot figure out why it saying: Tile: unidentified identifier. syntax error: identifier Tile.

Share this post

Link to post
Share on other sites
I had a feeling that was the problem..
here's the top of main.h

#ifndef __MAIN_H__
#define __MAIN_H__
#include <windows.h>
#include "player.h"
#include "gfx.h"
#include "input.h"
#include "defines.h"
#include "logger.h"
#include "maps.h"

extern HINSTANCE g_hInstance;
extern HWND g_hWnd;
extern Logger Log;

Share this post

Link to post
Share on other sites
I think the problem is tile.h include the main.h, which then tries to include maps.h which then in turn is trying to reference the tile class before it's even been defined.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!