STL vector<MyClass> problem

Hello!

I am working on a basic game in SDL/OpenGL its a tilebased tower-defence game.

I was gonna make a function that loads a tilemap to a vector that have this format:

std::vector< std::vector<tile> >

But for some reason i get error: C3203 and C2955.

I have done a similar tilemap loader, but that vector just stored ints. And it worked really good.

Now i am gonna post two header files. its the tile.h header file and the functions namespace header file.

(i assume you can understand what theyre for)

This is probaly the first project i use namespaces for, please tell me if im using it wrong!

thanks in advance!

EDIT: The problem was a circular dependency, Check Peter87 reply for a good answer!


Here is tile.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#ifndef _TILE_H
#define _TILE_H

#include <SDL.h>
#include <SDL_opengl.h>

#include "functions.h"
#include "global.h"

class tile
{
public:
	tile(float x, float y);
	~tile(void);

	void Update(global::Coord2D Mouse);
	void Render();

private:
	global::FloatRect box;
	bool MouseOver;
	int type;
};

#endif 


here is the functions namespace. I get error at the row where i declare
void LoadMap( std::vector< std::vector<tile> > * map );

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#ifndef _FUNCTIONS_H
#define _FUNCTIONS_H

#include <vector>

#include "global.h"
#include "tile.h"

namespace functions
{
	namespace collisions
	{
		bool CheckRectCollision(global::FloatRect rect1, global::FloatRect rect2);
		bool CheckIfMouseIsInside(global::Coord2D Mouse, global::FloatRect rect);
	}

	namespace map
	{
		void LoadMap( std::vector< std::vector<tile> > * map );
	}
}

#endif 
Last edited on
You have a circular dependency. It doesn't look like tile.h needs to include functions.h so just remove that include. This should be enough but if you want I think you can get rid of #include "tile.h" from functions.h if you forward declare the tile class instead of including it
class tile;
Last edited on
I think there are no telepathists who can say what error mesages do these error codes have.
I think there are no telepathists who can say what error mesages do these error codes have.


No but google can!


I will take a look at your reply tomorrow im too tired now. Thanks for responding tho.
> I will take a look at your reply tomorrow im too tired now.

Yes. Too tired to realize that after the post by Peter87, you could mark this as solved.
Topic archived. No new replies allowed.