Jump to content
  • Advertisement
Sign in to follow this  
Fantastic Jason

std:: Vectors & Lists

This topic is 4273 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
Guest Anonymous Poster
#include

using namespace std;

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!