string( msdn Libraries )

string:

A type that describes a specialization of the template class basic_string with elements of type char as a string.

typedef basic_string<char> string;
Example
// 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;
}
Output
The strings s1 & s2 are equal.

basic_string Class


The sequences controlled by an object of template class basic_string
are the Standard C++ string class and are usually referred to as strings,
but they should not be confused with the null-terminated C-strings used throughout
the Standard C++ Library. The string class is a container that enables
the use of strings as normal types, such as using comparison and
concatenation operations, iterators, and STL algorithms and copying
and assigning with class allocator managed memory.

template <
   class CharType,
   class Traits=char_traits<CharType>, 
   class Allocator=allocator<CharType> 
>
class basic_string





Parameters
CharType
The data type of a single character to be stored in the string.
The Standard C++ Library provides two specializations of this
template class, with the type definitions
string , for elements
of type char, and
wstring , for elements of type wchar_t.
Traits
Various important properties of the CharType elements in a
basic_string specialization are described by the class Traits.
Allocator
The type that represents the stored allocator object that
encapsulates details about the string's allocation and deallocation
of memory. The default value is allocator<Type>.

Many member functions require an operand sequence of elements.
You can specify such an operand sequence several ways.




 










  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值