共用方式為


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