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

📄 string.operators.html

📁 PTypes (C++ Portable Types Library) is a simple alternative to the STL that includes multithreading
💻 HTML
字号:
<html><!-- #BeginTemplate "/Templates/tmpl.dwt" --><head><!-- #BeginEditable "doctitle" --> <title>PTypes: string: operators</title><!-- #EndEditable --> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link rel="stylesheet" href="styles.css"></head><body bgcolor="#FFFFFF" leftmargin="40" marginwidth="40"><p><a href="../index.html"><img src="title-1.7.gif" width="213" height="34" alt="C++ Portable Types Library (PTypes) Version 1.7" border="0"></a> <hr noshade><!-- #BeginEditable "body" --> <p class="hpath"><a href="index.html">Top</a>: <a href="basic.html">Basic types</a>: <a href="string.html">string</a>: Operators</p><blockquote> <pre class="lang">#include &lt;ptypes.h&gt;<span class="comment">// assignment</span>string& string::operator=  (const char* sc);string& string::operator=  (char c);string& string::operator=  (const string& s);void    assign(string& s, const char* buf, int len);<span class="comment">// concatenation</span>string& string::operator+= (const char* sc);string& string::operator+= (char c);string& string::operator+= (const string& s);string  string::operator+  (const char* sc) const;string  string::operator+  (char c) const;string  string::operator+  (const string& s) const;friend  string operator+   (const char* sc, const string& s);friend  string operator+   (char c, const string& s);<span class="comment">// comparison</span>bool    string::operator== (const char* sc) const;bool    string::operator== (char) const;bool    string::operator== (const string&) const;bool    string::operator!= (const char* sc) const;bool    string::operator!= (char c) const;bool    string::operator!= (const string& s) const;<span class="comment">// indexed character access, 0-based</span>char&   string::operator[] (int I);</pre></blockquote><p>The string class defines the following binary operators: assignment (<span class="lang">=</span>), concatenation (<span class="lang">+</span>), concatenation with assignment (<span class="lang">+=</span>) and comparison (<span class="lang">==</span>,<span class="lang"> !=</span>). At least one of the operands (either left or right) must be of type <span class="lang">string</span>. Another operand can be one of the following: <span class="lang">char</span>, <span class="lang">char*</span> or <span class="lang">string</span>.</p><p>Indexed access operator allows to store or retrieve a value of an individual character. The index is 0-based. When compiled with either DEBUG or _DEBUG conditional symbol, bounds checking is performed for the indexed access; if the index is out of bounds (i.e. less than 0 or equals to or greater than the length of the string), an unrecoverable error is raised. The non-debugging version of the library never checks for index overlfows, thus making your program somewhat faster but less safe.</p><p><b>Examples</b></p><blockquote> <pre>string s1 = &quot;abc&quot;, s2 = 'd', s3;s3 = s1 + s2;s2 += &quot;ef&quot;;s3[2] = 'B';</pre></blockquote><p class="seealso">See also: <a href="string.constructors.html">Constructors/destructors</a>, <a href="string.typecasts.html">Typecasts</a>, <a href="string.manipulation.html">Manipulation</a></p><!-- #EndEditable --><hr size="1"><a href="../index.html" class="ns">PTypes home</a></body><!-- #EndTemplate --></html>

⌨️ 快捷键说明

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