String (MSDN Libraries)

xiaoxiao2021-03-06  42

String:

A Type That Describes a Specialization of the Template Class Basic_String with Elements of Type Char as a string.

Typedef Basic_String string; example // string_string.cpp

// compile with: / eHSC

#include

#include

int main ()

{

Using namespace std;

// Equivalent Ways to Declare An Object

// of type Basic_String

Const Basic_String 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;

Officer.

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 ,

Class allocator = allocator

>

Class Basic_StringParameters

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 Repesents The Stored Allocator Object That Encapsulates Details About The String's Allocation and deallocation of memory. The default value is allocator .

.

转载请注明原文地址:https://www.9cbs.com/read-74315.html

New Post(0)