i'm trying to learn about vectors in C++, but MSVC is being a bit anal about it. Anyone know why? Thanks...
#include <iostream>
#include <vector>
vector <int> test(50);
int main() {
system("PAUSE");
return 0;
}
Errors:
(4) error C2143: syntax error : missing ';' before '<'
(4) error C2501: 'vector' : missing storage-class or type specifiers
(4) error C2143: syntax error : missing ';' before '<'
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G
Peblo Custom ratings must be 50 characters or less
Registered 05/07/2002
Points 185
1st July, 2004 at 07:33:33 -
Captain Optimistic to the rescue!
Actually, I don't know anything about C++.
"Isn't it always amazing how we characterize a person's intelligence by how closely their thinking matches ours?"
~Belgarath
ps-i know nothing about vectors, and only the bear bones of c++(though im getting the hang of it, allegro rocks) so this is a bit of a stab in the dark
it's a nifty C++ feature called templates that let you make classes with member data/functions that take any kind of argument (int, in this case) so you don't have to do different versions of it (float,int, char etc)
oh and test is the name of the variable and 50 is the number of elements (Vectors are resizable arrays)
Edited by the Author.
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G
I was missing "using namespace std;". Didnt think i needed it
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G
You don't have to use 'using namespace std;', you can just use 'using std::vector;' or refer to it as std::vector if you're worried about any namespace conflicts
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G