In the Standard C++ Library, a string is actually a template class, named basic_string. The template argument represents the type of character that will be held by the string container. By defining strings in this fashion, the Standard C++ Library not only provides facilities for manipulating sequences of normal 8-bit ASCII characters, but also for manipulating other types of character-like sequences, such as 16-bit wide characters. The datatypes string and wstring (for wide string) are simply typedefs of basic_string, defined as follows:
typedef basic_string<char> string;
typedef basic_string<wchar_t> wstring;
Partager