⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 string.htm

📁 这是关于VC++中的STL容器的资料,包括了STL容器各个类之间关系以及类的说明
💻 HTM
📖 第 1 页 / 共 5 页
字号:
</pre>

<h3>Description</h3>
<p>
This begin() method returns a const iterator that points to the first element of the basic_string
object's character sequence.
</p>

<hr>

<pre>
<a name="c_str">
Method             c_str()</a>

Access             Public

Classification     Accessor

Syntax             const charT* c_str() const;

Parameters         None

Returns            This method returns a pointer to a the first
                   element of an array which represents the
                   character sequence of the current object.

</pre>

<h3Description<h3>
<p>
The c_str() method returns a pointer of type const charT that points to the 
first element of an array whose length is size() + 1. The first size() elements 
are equal in correspondence to the elements of the string controlled by *this 
and the last element is a null character specified by traits::eos().The pointer 
may not be valid after the string object has been modified.
</p>

<hr>
<pre>
<a name="capacity">
Method             capacity()</a>

Access             Public

Classification     Accessor

Syntax             size_type capacity() const;

Parameters         None

Returns            This method returns the number of characters 
                   allocated for the sequence.

</pre>

<h3>Description</h3>
<p>
The capacity() method returns the number of characters allocated for in the 
character sequence.
</p>

<hr>

<pre>
<a name="compare1">
Method             compare()</a>

Access             Public

Classification     Accessor

Syntax             int compare(const basic_string& str) const;

Parameters         <em>str</em> is the basic_string object compared to the
                   current object.

Returns            The method returns 0 if the character sequences of
                   the basic_string objects are equal.

</pre>

<h3>Description</h3>
<p>
The compare() method compares the basic_string <em>str</em> with the 
character sequence of the current
object. The comparison is performed by char_traits&lt;Ch&gt;'s compare(). 
0 is returned if the character sequences have the same value; a negative 
integer is returned if the current object's character sequence is 
lexicographically before <em>str</em>'s character sequence; a positive 
integer is returned otherwise.
</p>

<hr>
<pre>
<a name="compare2">
Method             compare()</a>

Access             Public

Classification     Accessor

Syntax             int compare(size_type pos1,
                               size_type n1,
                               const basic_string& str) const;

Parameters         <em>pos1</em> is the starting position in the character
                   sequence of the current object used in the
                   comparison.

                   <em>n1</em> is the length of the character sequence used in
                   the comparison.

                   <em>str</em> is the basic_string object compared to the
                   current object.

Returns            The method returns 0 if the character sequences of
                   the basic_string objects are equal.

</pre>

<h3>Description</h3>
<p>
The compare() method compares the basic_string <em>str</em> with the 
character sequence of the current
object. It compares current object's character sequence of length <em>n1</em> starting
at position <em>pos1</em> with the character sequence of <em>str</em>. The comparison 
is performed by char_traits&lt;Ch&gt;'s compare(). 0 is returned if the character sequences
have the same value; a negative integer is returned if the current object's character sequence is
lexicographically before <em>str</em>'s character sequence; a positive
integer is returned otherwise.
</p>

<hr>

<pre>
<a name="compare3">
Method             compare()</a>

Access             Public

Classification     Accessor

Syntax             int compare(size_type pos1,
                               size_type n1,
                               const basic_string& str,
                               size_type pos2,
                               size_type n2) const;

Parameters         <em>pos1</em> is the starting position in the character
                   sequence of the current object used in the
                   comparison.

                   <em>n1</em> is the length of the character sequence used in
                   the comparison.

                   <em>str</em> is the basic_string object compared to the
                   current object.

                   <em>pos2</em> is the starting position in the character
                   sequence of basic_string object str used in the
                   comparison.

                   <em>n2</em> is the length of the character sequence 
                   of the basic_string object str used in the 
                   comparison.

Returns            The method returns 0 if the character sequences of
                   the basic_string objects are equal.


</pre>
<h3>Description</h3>
<p>
The compare() method compares the basic_string <em>str</em> with the 
character sequence of the current
object. It compares current object's character sequence of length <em>n1</em> starting
at position <em>pos1</em> with the character sequence of <em>str</em> starting at position
<em>pos2</em> of length <em>n2</em>. The comparison
is performed by char_traits&lt;Ch&gt;'s compare(). 0 is returned if the character sequences
have the same value; a negative integer is returned if the current object's character sequence is
lexicographically before <em>str</em>'s character sequence; a positive
integer is returned otherwise.
</p>
<hr>

<pre>
<a name="compare4">
Method             compare()</a>

Access             Public

Classification     Accessor

Syntax             int compare(const charT* s) const;

Parameters         <em>s</em> points to the character array used in the
                   comparison.

Returns            The method returns 0 if the character sequences of
                   the basic_string objects are equal.


</pre>

<h3>Description</h3>
<p>
The compare() method compares the character sequence pointed to by <em>s</em>
with the character sequence of the current object. The comparison is performed by char_traits&lt;Ch&gt;'s compare(). 0 is returned if the character sequences
have the same value; a negative integer is returned if the current object's character sequence is
lexicographically before <em>s</em>'s character array; a positive
integer is returned otherwise.
</p>

<hr>

<pre>
<a name="compare5">
Method             compare()</a>

Access             Public

Classification     Accessor

Syntax             int compare(size_type pos1,
                               size_type n1,
                               const charT* s,
                               size_type n2 = npos) const;

Parameters         <em>pos1</em> is the starting position in the character
                   sequence of the current object used in the
                   comparison.

                   <em>n1</em> is the length of the character sequence used in
                   the comparison.

                   <em>s</em> points to the character array used in the
                   comparison.

                   <em>n2</em> is the length of the character array s used in
                   the comparison.

Returns            The method returns 0 if the character sequences of
                   the basic_string objects are equal.

</pre>

<h3>Description</h3>
<p>
The compare() method compares the character sequence pointed to by <em>s</em>
with the character sequence of the current object. It compares current object's character sequence of length <em>n1</em> starting
at position <em>pos1</em> with the character array pointed to by <em>s</em> 
of length <em>n2</em>.The comparison is performed by char_traits&lt;Ch&gt;'s compare(). 0 is returned if the character sequences
have the same value; a negative integer is returned if the current object's character sequence is
lexicographically before <em>s</em>'s character array; a positive
integer is returned otherwise.
</p>

<hr>

<pre>
<a name="copy">
Method             copy()</a>

Access             Public

Classification     Modifier

Syntax             size_type copy(charT* s, size_type n,
                                  size_type pos = 0) const;

Parameters         <em>s</em> points to the character array which
                   receives the copy of the character sequence of the
                   current object.
                   
                   <em>n</em> is the length of the current object's
                   character sequence to be copied.

                   <em>pos1</em> is the starting position in the character
                   sequence of the current object to be copied.

Returns            This method returns the number of characters
                   copied.

</pre>

<h3>Description</h3>
<p>
The copy() method copies the current object's character sequence starting 
at position <em>pos</em> with a length of <em>n</em> or to the end of the 
sequence, whichever comes first, to the character array pointed by <em>s</em>. 
A null object is not appended to the character array. The method
returns the number of characters copied.
</p>


<hr>

<pre>
<a name="data">
Method             data()</a>

Access             Public

Classification     Accessor

Syntax             const charT* data() const;

Parameters         None

Returns            This method returns a pointer that points to the
                   first element of an array whose elements corresponds
                   to the character sequence of the current object.

</pre>

<h3>Description</h3>
<p>
The data() method returns a pointer of type const charT that points to the 
first element of an array whose first size() elements are equal in correspondence 
to the elements of the string controlled by *this if size() is nonzero. If size() == 0, 
then a non-null pointer that is copyable and can have 0 added to it is returned. 
The pointer may not be valid after the string object has been modified.
</p>

<hr>

<pre>
<a name="empty">
Method             empty()</a>

Access             Public

Classification     Accessor

Syntax             bool empty() const;

Parameters         None

Returns            This method returns true if the string object has
                   no character sequence.

</pre>

<h3>Description</h3>
<p>
The empty() method returns true if the string object has no character 
sequence.
</p>

<hr>

<pre>
<a name="end1">
Method             end()</a>

Access             Public

Classification     Accessor

Syntax             iterator end();

Parameters         None

Returns            This method returns an iterator that points to the
                   past-the-end value of the character sequence of the 
                   current object.

</pre>

<h3>Description</h3>
<p>
The end() method returns an iterator that points to the past_the_end value of the basic_string
object's character sequence.
</p>

<hr>

<pre>
<a name="end2">
Method             end()</a>

Access             Public

Classification     Accessor

Syntax             const_iterator end() const;

Parameters         None

Returns            This method returns a const iterator that points to 
                   the past-the-end value of the character sequence of 
                   the current object.


</pre>

<h3>Description</h3>
<p>
The end() method returns a const iterator that points to the past_the_end 
value of the basic_string object's character sequence.
</p>

<hr>

<pre>
<a name="erase1">
Method             erase()</a>

Access             Public

Classification     Modifier

Syntax             basic_string& erase(size_type pos = 0,
                                       size_type n = npos);

Parameters         <em>pos</em> is the starting position in the character
                   sequence of the current object to be erased.

                   <em>n</em> is the number of characters to be erased.

Returns            This method returns a pointer to the calling object.

</pre>

<h3>Description</h3>
<p>
This erase() method removes characters starting at position <em>pos</em>
to the end of the sequence or <em>n</em>
characters, whichever comes first. The method returns *this. An exception out_of_range
is thrown if pos &gt; size().
</p>

<hr>

<pre>
<a name="erase2">
Method             erase()</a>

Access             Public

Classification     Modifier

Syntax             iterator erase(iterator position);

Parameters         <em>position</em> is the position of the character in the 
                   sequence of the current object to be erased.      

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -