Sign in to follow this  
Fantastic Jason

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 this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this