string (<string>)

描述basic_string与类型 char 的元素的模板选件类专用化作为字符串的类型。

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

备注

用于字符串构造函数列表参见 basic_string::basic_string

示例

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

int main( ) 
{
   using namespace std;

   // Equivalent ways to declare an object 
   // of type basic_string <char>
   const basic_string <char> s1 ( "test" );
   string s2 ( "test" );   // Uses the typedef for string

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

要求

标头: <string>

命名空间: std

请参见

参考

basic_string Class

basic_string::basic_string