# std:: Vectors & Lists

## Recommended Posts

Okay, Please help.... I have seen several tutorials on usinf std::vector...thats cool. My problem comes when I have a class and want to use a vector in a class. For example, I have a 2d Tiled Map class. I want to use the vector as an array of tiles for example: class MyMap { private: std:: vector<int> MyMap; .... ...etc Everytime I try something like this i get all sorts of compiler errors about the vector line of code.... What am I doing wrong? Thanks very much in advance... Fantastic Jason

##### Share on other sites
Guest Anonymous Poster
#include

using namespace std;

##### Share on other sites
jpetrie    13099
Without seeing actual code it is hard to say -- could be many things. The most likely culprit, however, is that you are missing the #include directive for vector:
#include <vector>class MyClass{  std::vector< int > foo;  //...};

If that does not fix it, the problem most likely lies elsewhere; post code.

EDIT:
using namespace std; is not required, especially if you explicitly qualify the namespace (e.g., std::vector) as you did. using namespace std; in headers is a very bad practice to get into, since it pollutes the entire global namespace of any translation unit including said header from the point of inclusion onward; this essentially defeats the purpose of namespaces.