basic_string::size_type

可表示组件和索引数字符串中的无符号整数类型。

typedef typename allocator_type::size_type size_type;

备注

它与 allocator_type::size_type等效。

对于类型 字符串,它与 size_t等效。

示例

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

int main( ) 
{
   using namespace std;
   string str1 ( "Hello world" );

   basic_string <char>::size_type sizeStr1, capStr1;
   sizeStr1 = str1.size (  );
   capStr1 = str1.capacity (  );

   cout << "The current size of string str1 is: " 
        << sizeStr1 << "." << endl;
   cout << "The capacity of string str1 is: " << capStr1 
         << "." << endl;
}
  
  

要求

标头: <string>

命名空间: std

请参见

参考

basic_string Class