Getting vectors to work
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!"
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;
vector<TYPENAMETOBEHEALDINVECTOR> myVector;
For example a vector of ints would look like this:
vector<int> myVectorOfInts;
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
vector a;
Vectors are just dynamic arrays, so you have to be holding something.
-------------------
The Reindeer Effect
Insomniac Software
Also you need to insert this line right after the #include:
using namespace std;
Otherwise you need to write std::vector a;
-------------------
The Reindeer Effect
Insomniac Software
using namespace std;
Otherwise you need to write std::vector a;
-------------------
The Reindeer Effect
Insomniac Software
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.
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]
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]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement