Skip to main content
gamedev.net
🔒 Locked

Vectors not working

Started by Sickilla Jul 31, 2002 at 4:56 PM 1 replies 350+ views
Original Post
Sickilla
Sickilla
Exactly what headers do you have to include to use vectors? i tried putting , and but when i put the following line of code in my program (minus the //): //vector particles; it gives me these errors: C:\Code\Games\CDXDemo\ParticleSys.h(84) : error C2143: syntax error : missing ';' before '<' C:\Code\Games\CDXDemo\ParticleSys.h(84) : error C2501: 'vector' : missing storage-class or type specifiers C:\Code\Games\CDXDemo\ParticleSys.h(84) : error C2059: syntax error : '<' C:\Code\Games\CDXDemo\ParticleSys.h(84) : error C2238: unexpected token(s) preceding ';' this would normally mean that i don't have the required files included but i do. X4J [edited by - Sickilla on July 31, 2002 6:15:13 PM] [edited by - Sickilla on July 31, 2002 6:15:43 PM]
X4J
Zipster
Zipster
vector is the file. No extension, just that:

#include <vector>


To use it, you either need to explicity specify the "std" namespace each time, or make an early blanket statement:

Either:

std::vector myVec;


Or:

// Once at beginning of file
using namespace std;

vector myVec;
Stoffel
Stoffel
and beware this forum strips < and > unless you''re in source blocks. Here''s a working sample to get you started:

  
//main.cpp

#include <vector>

using namespace std; // never do this in a header file


int main ()
{
vector<int> intVec;
intVec.push_back (42);
return intVec.size ();
}

(should return 1)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.