Archived

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

Getting vectors to work

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