Jump to content
  • Advertisement

Archived

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

Eric

C++ string class

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Apparently there is a standard C++ "string" class, but my MSVC compiler refuses to acknowledge it... test.cpp: #include <string> string blah; Compiling this gives me error C2146: syntax error : missing ';' before identifier 'blah' error C2501: 'string' : missing storage-class or type specifiers I've found string's definition in the file "xstring": typedef basic_string < char, char_traits < char >, allocator < char > > string; I assume that including "string" in my test file is supposed to somehow also include xstring, thereby giving me string's definition. Also, ya know that type information that pops up while you're typing in MSVC? It knows that blah is a string, and it knows what a string is. But still my test file won't compile. Any ideas? Edited by - Eric on February 17, 2002 9:21:42 PM

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
std::string blah;

or

using namespace std;
string blah;

Share this post


Link to post
Share on other sites
That string class is part of the STL (Standard Template Libarary). All members of the STL are wrapped in the namespace std, so you need either to qualify any references or use using
  
#include <string>
std::string mystring;

...or...
  
#include <string>
using namespace std;
string mystring;

Share this post


Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!