Nonsensical errors

I've been working on my first c++ project and started getting some build errors with this code but they don't make any sense to me.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#pragma once
#include<SFML/Graphics.hpp>
#include "Entity.h"
#include "Types.h"



	class AreaMap
	{
	public:
		int worldX, worldY;
		
		std::vector<Entity*> mapCells[25][25];
		sf::Text areaName;
		
		AreaMap();
		~AreaMap();
	};


Error C2065 'Entity': undeclared identifier

Error C2059 syntax error: '>'

Error C2148 total size of array must not exceed 0x7fffffff bytes

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#pragma once
#include<SFML/Graphics.hpp>
#include "AreaMap.h"
#include "Types.h"


class Entity
{
	
public:
	std::string name;
	int type;
	sf::Sprite icon;
	int id;
	Coor coor;

	void setIcon(sf::Texture* texture);


	Entity();
	virtual ~Entity();
};


There's no way 625 elements exceeds whatever that gigantic number is and I've used that entity class in other parts of the program with no problem. Any idea what the problem might be?
AreaMap.h and Entity.h are including each other. The preprocessor can't resolve inclusion cycles, so you'll invariably be left with an invalid translation unit.
It looks to me like Entity.h doesn't need to include AreaMap.h.

Is an array of vectors really the data structure you want to use?
Thanks! I'll have to watch for those unnecessary includes.

I've actually been pondering if arrays are best way to go for map tiles. The only other way I can think of to do it is to just have a big list of objects and their coordinates and search through the whole list to find the ones at a particular set of coordinates.
So I assume each cell can contain more than one Entity. In that case it's fine, but you should have a MapCell (or whatever) class that contains whatever data a cell needs.
is that entity pointer one entity, or possibly a block of them?
if its just the one entity, the vector isnt doing anything, you may as well just have a 2d array of entity *s.
... it seems to me that an area would be cut up into grids and each cell would have one and only one texture. Since cells in many programs may reuse the same texture, a pointer back to one copy of it makes sense to me.

break apart what you have and 'rubber duck' explain what each piece is doing (esp that vector).
There's one to point at the terrain to draw, but also any objects or creatures on the tile are added to it.
Thanks! I'll have to watch for those unnecessary includes

If the extra files are creating problems rather than solving them, you have too many. Consider creating fewer files, especially if your program is currently small or you are currently the only programmer.
Topic archived. No new replies allowed.