#include "SDL.h"//duh
#include "Tile.h"// so we can hav the tile lists
#include <string.h>
#include <vector.h>// because they are better and more flexible then arrays
#pragma once
class Map
{
protected:
int m_tileHeight;
int m_tileWidth;//size of the tiles used on this preticular map
int m_Height; // in tiles
int m_Width; // in tiles
public:
Map(int width, int height, vector<Tile*> tile,int tileheight, int tilewidth,vector<string> szFiles);//intializing all member variables
vector<string> m_szFiles;
Tile *m_tilelist[];
vector<Tile*> m_tilelistvec;
vector<vector<int> > MapOver;
void SetFiles(vector<string> ok);
int GetHeight() {return m_Height*m_tileHeight;};
int GetWidth() {return m_Width*m_tileHeight;};
void LoadMap(int MapOver[]);//may be used if i decide to load map from a txt file
void InitImages(vector<string> szFiles, vector<Tile*> tilelist);
void InitImages(vector<Tile*> tilelist);
void InitMap(vector< vector <int> > Map);
void DrawMap(SDL_Surface *screen,vector< vector<int> > MapOver,int tilelistsize);
};
compiler rejecting string?
ok i dont know why but my compiler seems to be rejection string heres my code
i get this error "14 C:\Dev-Cpp\projects\HI\Map.h `string' was not declared in this scope
You need to put std:: in front of it, or put a using namespace std; at the top of your file.
I would also recommend using the non .h versions of the include files (#include <vector> and #include <string>).
I would also recommend using the non .h versions of the include files (#include <vector> and #include <string>).
Two things:
1) There is no ".h" at the end of the C++ standard library headers. It should be
#include <string>
#include <vector>
2) string and vector are within the namespace "std". In any of your own header files, it is best to prefix any use of "string" or "vector" with "std::", thus becoming "std::string" or "std::vector". In your own .cpp files, it is usually considered acceptable to add the line "using namespace std;" near the top, so that you don't have to type out "std::" all the time.
1) There is no ".h" at the end of the C++ standard library headers. It should be
#include <string>
#include <vector>
2) string and vector are within the namespace "std". In any of your own header files, it is best to prefix any use of "string" or "vector" with "std::", thus becoming "std::string" or "std::vector". In your own .cpp files, it is usually considered acceptable to add the line "using namespace std;" near the top, so that you don't have to type out "std::" all the time.
Additionally, theres no point in adding #pragma once to a source file. #pragma once tells the compiler to only compile this file once. Which it does with source files anyway.
Oops, I need to read posts better :P I just saw the #include directives and assumed it was a source file...
#pragma once doesnt work with gcc/mingw(dev-c++'s compiler) you have to youse old fasioned include guards.
#ifndef HEADERSNAME_H__
#define HEADERSNAME_H__
//code here
#endif
#ifndef HEADERSNAME_H__
#define HEADERSNAME_H__
//code here
#endif
not if you use version 4.9.9.0 you right it dosnt work with the older versions
you should get the latest version
you should get the latest version
Hmm i have been under the impression that every version of gcc up to the latest 3.3 didnt support the #pragma preprocessor, I still prefer #ifndef#define#endif for portability though.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement