Archived

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

Draxis

Minor Problem With Included Files

Recommended Posts

According to this C++ book I''m reading, you can define includes like this: #include <string> Instead of like this: #include <string.h> But I can''t seem to use #include <string> with my VC++ 6.0 compiler. Does VC++ support it? Or is there some setting I''m missing.

Share this post


Link to post
Share on other sites
quote:
Original post by Draxis
According to this C++ book I''m reading, you can define includes like this:
#include <string>
Instead of like this:
#include <string.h>

Those are completely different headers. <string.h> is the old C-style string manipulation header, containing functions like strlen, strncpy and so on. <string> is the new C++ Standard Template Library (STL) string class, std::string. Note the std:: prefix; this is a reference to the std namespace in which all STL constructs are defined. Here''s how you use it:
#include <string>
// option 1: use the unqualified symbol
std::string str1;
// option 2: import only the symbol you want
using std::string;
string str2;
// option 3: import the entire namespace
using namespace std;
string str3;

Look up namespace and the using keyword in MSDN.

I wanna work for Microsoft!
[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!

Share this post


Link to post
Share on other sites