Header stringfwd

This non-standard header can be used to forward declare basic_string (much like <iosfwd> forward declares streams). There is also a <stringfwd.h> that forward declares basic_string and places it into the global namespace.

Note: The header <stringfwd> is a non-standard header.
Listing: Header <stringfwd> Synopsis
namespace std { // Optional
template <class T>   class allocator;

template<class charT>   struct char_traits;

template <class charT, class traits, class Allocator> 

class basic_string;

typedef basic_string <char, char_traits<char>, allocator<char> > 

string;

typedef basic_string 

<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wstring;

}

Including <stringfwd> allows you to use a string object.

Listing: Example of <stringfwd> Inclusion of std::string
#include <stringfwd>
class MyClass

{

....

       std::string* my_string_ptr;

};

The headers <stringfwd.h> and <string> can be used in combination to place string into the global namespace, much like is done with other <name.h> headers. The header <string.h> does not work because that is a standard C header.

Listing: Example of Stringfwd usage
#include <stringfwd.h>
#include <string>

int main()

{

   string a("Hi");   // no std:: required

   return 0;

}