Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Blue*Omega

Getting vectors to work

This topic is 6010 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

Hmm... for some reason I can''t get my vectors to work. I think I''m leaving out a library or include somewhere, but this code won''t work: vector ListOfObj; it keeps telling me that there''s a missing ";" before the "vector", but there''s not. I have #include <vector> in there, but maybe I need something else? Any ideas? ----------------------------- Vash the Stampede "Love & Peace!"

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Its a template. You need to use it like this.
vector<TYPENAMETOBEHEALDINVECTOR> myVector;

For example a vector of ints would look like this:
vector<int> myVectorOfInts;

Share this post


Link to post
Share on other sites
A vector is a container. You must specify something such as:

vector a;

Vectors are just dynamic arrays, so you have to be holding something.

-------------------
The Reindeer Effect
Insomniac Software

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Did you make a typo Rein?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I repeat again vectors as specified in the standard C++ library are templates therefore they must be intiallized as such. Your method won''t work either Rein.

Share this post


Link to post
Share on other sites
The brackets probably aren''t showing up because they are HTML tag delimiters..

Share this post


Link to post
Share on other sites
yeah Reindeer said the right thing he just typed the brackets instead of & l t ; or & g t ; (spaces included so they would show up).

the correct usage of vector (that reindeer got right but doesn't show up:

#include <vector>
using namespace std;

vector<int> a;

now you can use a as a vector to contain ints.

-me

[edited by - Palidine on June 6, 2002 2:18:20 AM]

Share this post


Link to post
Share on other sites
Hmph... I did put the brackets in my original post, but the HTML stuff killed em. Reindeer''s suggestion did it though. Thanks!

-----------------------------

Vash the Stampede

"Love & Peace!"

Share this post


Link to post
Share on other sites

  • 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!