Archived

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

Matheass

Standard C++ Template Library

Recommended Posts

I've two questions: 1) I wanted to use the following syntax: std::vector<std::string> names; This code causes 4 compiler warnings. Whats wrong with this code? 2) Do you know a link to a good tutorial or article about the use of the c++ Standard Template Library? The link at gamedev.net's articles doesn't work Thank you for your help! [edited by - Matheass on November 16, 2003 6:30:41 AM] [edited by - Matheass on November 16, 2003 6:31:13 AM]

Share this post


Link to post
Share on other sites
Hi,

I think it's the compiler... the statement is too long

try this:

using std::string;
using std::vector;

typedef vector < string > StrVector;
StrVector names;

names.push_back( "buck wheat" );

Hope this helps.... I think there are some switches to correct this problem... but I haven't used VC++ 6.0 in dog ages... so I can't remember

[edited by - vetroXL on November 16, 2003 7:16:28 AM]

[edited by - vetroXL on November 16, 2003 7:17:47 AM]

[edited by - vetroXL on November 16, 2003 7:18:20 AM]

Share this post


Link to post
Share on other sites
The index over at SGI is also worth a read, if you need a quick reference . You should have a basic understanding of STL though, their descriptions don't qualify as a tutorial .

I can't read the warnings you get, the page doesn't work. But I remember having had similar issues once (VC++ 6.0).

typedef std::string String;

std::vector<String> names;

This should probably do the trick. It worked for me, at least.

//edit: curse you pointy brackets!

[edited by - Wildfire on November 16, 2003 7:19:08 AM]

Share this post


Link to post
Share on other sites
quote:
Original post by Matheass
1) I wanted to use the following syntax:
std::vector<<std::string>std::string> names;

This code causes 4 compiler warnings.
Whats wrong with this code?

Nothing, just MSVC++ that is choking on too long debug information.

You can disable there warnings by adding this line (before including any STL headers):

#pragma warning (disable : 4786)

(I *think* that is the correct syntax, cannot verify at the moment)

Share this post


Link to post
Share on other sites