Udostępnij za pośrednictwem


wstring

Declares a string of wide characters. wstring is a typedef that specializes the template class basic_string to contain wchar_t string data. wstring inherits the capabilities of the basic_string class; this includes operators and methods.

Other typedefs that specialize basic_string include string, u16string, and u32string. For more information, see <string> Members.

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

Example

// string_wstring.cpp
// compile with: /EHsc
#include <string>
#include <iostream>

int main( ) 
{
   using namespace std;
   // Equivalent ways to declare an object of type
   // basic_string <wchar_t>
   const basic_string <wchar_t> s1 ( L"abc" );
   wstring s2 ( L"abc" );   // Uses the typedef for wstring

   // Comparison between two objects of type basic_string <wchar_t>
   if ( s1 == s2 )
      cout << "The strings s1 & s2 are equal." << endl;
   else
      cout << "The strings s1 & s2 are not equal." << endl;
}
The strings s1 & s2 are equal.

Requirements

Header: <string>

Namespace: std

See Also

Reference

basic_string Class

Other Resources

<string> Members