#### Archived

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

# Where can I get vector&string?

This topic is 5214 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Anyone know where I can get the C++ header files and ? They appear on my comp but when I try to use code like that below, the compiler (VC++6) decides to tell me that string is not defined or ignore vector altogether: #include <string> #include <vector> void main() { vector<'string> iam; } would yield c:\blah.cpp(12) : error C2065: 'string' : undeclared identifier [edited by - uber_n00b on April 13, 2004 8:43:43 PM]

##### Share on other sites
Make sure the header files are located in the path that VS searches for standard includes. I'd reckon this should be setup upon installation automatically, though...

Also, you need to qualify your declarations with the std:: namespace identifier, as all standard C++ library code is in the std namespace:
std::string str;

You can use a using namespace std; directive at the top of your source file if you wish to avoid using all of the std:: qualifiers.

Finally, classes such as vector are templated; that is, they need to be declared with a type specifier:
std::vector< int> intvec;            // Vector of intsstd::vector< SomeStruct> structvec;  // Vector of SomeStructsstd::vector< float *> floatptrvec;   // Vector of ptrs to float

Golem
Blender--The Gimp--Python--Lua--SDL

[edited by - VertexNormal on April 13, 2004 8:49:00 PM]

##### Share on other sites
Ok I will try that now. For some reason 'using namespace std;' doesn't work on my new comp though but worked fine on the old one with the same compiler. Any ideas on that one?'

Edit - While it did reduce my errors I still get fundamental problems with data types. I don't understand why my compiler wont recognize something that is written on practically every C++ website.

[edited by - uber_n00b on April 13, 2004 8:57:39 PM]

##### Share on other sites
Make sure your include directories for VC++ are actually valid. When I''ve been teaching people to use the thing I''ve had incidents where they simply delete some important include directory.
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE
Make sure this, or something very similar to it (depending on where you installed Visual Studio) appears in the include directories.

If it does, try this snippet of code:
#include <vector>#include <string>int main(){    std::vector<std::string> test;    return 0;}

It should work. If it doesn''t, post the errors here and we''ll work it out, because something is seriously wrong. If it does work, try this next:
#include <vector>#include <string>using namespace std;int main(){    vector<string> test;    return 0;}

Now I''ve used the using directive to avoid having to write std:: everywhere. If this works, you''re good to go. If not, post the errors.

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 10
• 14
• 30
• 13
• 11
• ### Forum Statistics

• Total Topics
631790
• Total Posts
3002363
×