{"id":76061,"date":"2026-02-13T23:05:23","date_gmt":"2026-02-13T15:05:23","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/76061.html"},"modified":"2026-02-13T23:05:23","modified_gmt":"2026-02-13T15:05:23","slug":"%e3%80%8astl-string-%e5%ba%95%e5%b1%82%e5%a4%8d%e5%88%bb%ef%bc%9a%e5%8a%a8%e6%80%81%e6%95%b0%e7%bb%84%e3%80%81%e6%8b%b7%e8%b4%9d%e6%8e%a7%e5%88%b6%e4%b8%8e%e6%80%a7%e8%83%bd%e4%bc%98%e5%8c%96%e3%80%8b","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/76061.html","title":{"rendered":"\u300aSTL string \u5e95\u5c42\u590d\u523b\uff1a\u52a8\u6001\u6570\u7ec4\u3001\u62f7\u8d1d\u63a7\u5236\u4e0e\u6027\u80fd\u4f18\u5316\u300b"},"content":{"rendered":"<p><span style=\"color:#0d0016\">\u63d0\u8d77 C&#043;&#043; \u4e2d\u7684 string&#xff0c;\u60f3\u5fc5\u4e0d\u5c11\u4eba\u90fd\u6709\u8fc7\u8fd9\u6837\u7684\u611f\u89e6&#xff1a;\u521d\u5b66\u65f6\u60ca\u53f9\u4e8e\u5b83\u529f\u80fd\u7684\u4e30\u5bcc\u4e0e\u4fbf\u6377&#xff0c;\u603b\u5fcd\u4e0d\u4f4f\u611f\u6168\u8fd9\u4efd \u201c\u5f00\u7bb1\u5373\u7528\u201d \u7684\u795e\u5947&#xff1b;\u6df1\u5165\u5b66\u4e60\u540e\u624d\u53d1\u73b0&#xff0c;\u8fd9\u4efd\u770b\u4f3c\u7b80\u5355\u7684 \u201c\u795e\u5947\u201d \u80cc\u540e&#xff0c;\u85cf\u7740\u52a8\u6001\u5185\u5b58\u7ba1\u7406\u3001\u62f7\u8d1d\u63a7\u5236\u3001\u8fd0\u7b97\u7b26\u91cd\u8f7d\u7b49\u5c42\u5c42\u7cbe\u5de7\u7684\u5e95\u5c42\u8bbe\u8ba1<\/span>\u3002<\/p>\n<p>std::string\u7684\u4f7f\u7528\u00a0 \u70b9\u51fb\u53ef\u4ee5\u770b\u5230\u6807\u51c6\u5e93\u4e2dstring\u7684\u4e3b\u8981\u529f\u80fd\u3002<\/p>\n<p id=\"main-toc\">\u76ee\u5f55<\/p>\n<p id=\"%E7%AC%AC%E4%B8%80%E6%AD%A5%EF%BC%9A%E5%BC%80%E4%B8%80%E4%B8%AAstring.h%E7%9A%84%E5%A4%B4%E6%96%87%E4%BB%B6-toc\" style=\"margin-left:40px\">\u7b2c\u4e00\u6b65&#xff1a;\u5f00\u4e00\u4e2astring.h\u7684\u5934\u6587\u4ef6<\/p>\n<p id=\"1.%20%E4%BB%A3%E7%A0%81%E7%BB%93%E6%9E%84%E5%88%86%E6%9E%90-toc\" style=\"margin-left:80px\">1. \u4ee3\u7801\u7ed3\u6784\u5206\u6790<\/p>\n<p id=\"1.%E6%9E%84%E9%80%A0%E5%87%BD%E6%95%B0%EF%BC%9A-toc\" style=\"margin-left:40px\">1.\u6784\u9020\u51fd\u6570&#xff1a;<\/p>\n<p id=\"%C2%A0%20%C2%A0%20%C2%A0%20%C2%A0%20%E6%B5%85%E6%8B%B7%E8%B4%9D%EF%BC%9A-toc\" style=\"margin-left:80px\">\u00a0 \u00a0 \u00a0 \u00a0 \u6d45\u62f7\u8d1d&#xff1a;<\/p>\n<p id=\"%C2%A0%20%C2%A0%20%C2%A0%20%C2%A0%20%E6%B7%B1%E6%8B%B7%E8%B4%9D%EF%BC%9A-toc\" style=\"margin-left:80px\">\u00a0 \u00a0 \u00a0 \u00a0 \u6df1\u62f7\u8d1d&#xff1a;<\/p>\n<p id=\"%E6%A0%B8%E5%BF%83%E6%80%9D%E8%B7%AF%EF%BC%9A-toc\" style=\"margin-left:120px\">\u6838\u5fc3\u601d\u8def&#xff1a;<\/p>\n<p id=\"%E4%BC%98%E5%8A%BF%EF%BC%9A-toc\" style=\"margin-left:120px\">\u4f18\u52bf&#xff1a;<\/p>\n<p id=\"%E5%BB%B6%E4%BC%B8%EF%BC%9A%E6%8B%B7%E8%B4%9D%E8%B5%8B%E5%80%BC%E8%BF%90%E7%AE%97%E7%AC%A6%E4%B9%9F%E5%8F%AF%E4%BB%A5%E7%94%A8%E8%BF%99%E4%B8%AA%E5%86%99%E6%B3%95-toc\" style=\"margin-left:80px\">\u5ef6\u4f38&#xff1a;\u62f7\u8d1d\u8d4b\u503c\u8fd0\u7b97\u7b26\u4e5f\u53ef\u4ee5\u7528\u8fd9\u4e2a\u5199\u6cd5<\/p>\n<p id=\"2.%E6%9E%90%E6%9E%84%E5%87%BD%E6%95%B0%EF%BC%9A-toc\" style=\"margin-left:40px\">2.\u6790\u6784\u51fd\u6570&#xff1a;<\/p>\n<p id=\"3.%E5%B8%B8%E7%94%A8%E6%88%90%E5%91%98%E5%87%BD%E6%95%B0%EF%BC%9A-toc\" style=\"margin-left:40px\">3.\u5e38\u7528\u6210\u5458\u51fd\u6570&#xff1a;<\/p>\n<p id=\"%C2%A0%20%C2%A0%20%C2%A0%20%C2%A0%201.iterator%EF%BC%88%E8%BF%AD%E4%BB%A3%E5%99%A8%EF%BC%89-toc\" style=\"margin-left:80px\">\u00a0 \u00a0 \u00a0 \u00a0 1.iterator&#xff08;\u8fed\u4ee3\u5668&#xff09;<\/p>\n<p id=\"%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A02.%E5%B8%B8%E8%B0%83%E7%94%A8%E7%9A%84%E5%87%BD%E6%95%B0%E6%88%96%E7%AE%80%E5%8D%95%E7%9A%84%E5%87%BD%E6%95%B0-toc\" style=\"margin-left:80px\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a02.\u5e38\u8c03\u7528\u7684\u51fd\u6570\u6216\u7b80\u5355\u7684\u51fd\u6570<\/p>\n<p id=\"%E8%A1%A5%E5%85%85%EF%BC%9A-toc\" style=\"margin-left:120px\">\u8865\u5145&#xff1a;<\/p>\n<p id=\"4.%E8%BE%83%E5%A4%8D%E6%9D%82%E7%9A%84%E6%88%90%E5%91%98%E5%87%BD%E6%95%B0%C2%A0%20%C2%A0string.cpp-toc\" style=\"margin-left:40px\">4.\u8f83\u590d\u6742\u7684\u6210\u5458\u51fd\u6570\u00a0 \u00a0string.cpp<\/p>\n<p id=\"1.%E5%AE%9E%E7%8E%B0%EF%BC%8C%E6%97%A0%E6%B3%A8%E9%87%8A%E7%89%88%EF%BC%9A-toc\" style=\"margin-left:80px\">1.\u5b9e\u73b0&#xff0c;\u65e0\u6ce8\u91ca\u7248&#xff1a;<\/p>\n<p id=\"2.%E4%BB%A3%E7%A0%81%E6%B3%A8%E9%87%8A%E7%89%88-toc\" style=\"margin-left:80px\">2.\u4ee3\u7801\u6ce8\u91ca\u7248<\/p>\n<p id=\"5.%E8%BF%90%E7%AE%97%E7%AC%A6%E9%87%8D%E8%BD%BD%E5%AE%9E%E7%8E%B0%E5%AD%97%E7%AC%A6%E4%B8%B2%E6%AF%94%E8%BE%83%E5%92%8C%E8%BE%93%E5%85%A5%E8%BE%93%E5%87%BA%E5%8A%9F%E8%83%BD-toc\" style=\"margin-left:40px\">5.\u8fd0\u7b97\u7b26\u91cd\u8f7d\u5b9e\u73b0\u5b57\u7b26\u4e32\u6bd4\u8f83\u548c\u8f93\u5165\u8f93\u51fa\u529f\u80fd<\/p>\n<p id=\"1.%E6%AF%94%E8%BE%83%E8%BF%90%E7%AE%97%E7%AC%A6%E9%87%8D%E8%BD%BD-toc\" style=\"margin-left:120px\">1.\u6bd4\u8f83\u8fd0\u7b97\u7b26\u91cd\u8f7d<\/p>\n<p id=\"2.%E6%B5%81%E8%BF%90%E7%AE%97%E7%AC%A6%E9%87%8D%E8%BD%BD-toc\" style=\"margin-left:120px\">2.\u6d41\u8fd0\u7b97\u7b26\u91cd\u8f7d<\/p>\n<p id=\"%E5%85%B3%E9%94%AE%E5%AE%9E%E7%8E%B0%E7%BB%86%E8%8A%82%E8%AF%B4%E6%98%8E-toc\" style=\"margin-left:80px\">\u5173\u952e\u5b9e\u73b0\u7ec6\u8282\u8bf4\u660e<\/p>\n<p id=\"6.%E5%AE%8C%E6%95%B4%E4%BB%A3%E7%A0%81-toc\" style=\"margin-left:40px\">6.\u5b8c\u6574\u4ee3\u7801<\/p>\n<p id=\"string.h-toc\" style=\"margin-left:80px\">string.h<\/p>\n<p id=\"string.cpp-toc\" style=\"margin-left:80px\">string.cpp<\/p>\n<hr id=\"hr-toc\" \/>\n<p>\u63a5\u4e0b\u6765&#xff0c;\u6211\u4eec\u6765\u8bb2\u600e\u4e48\u5b9e\u73b0string<\/p>\n<h3 id=\"%E7%AC%AC%E4%B8%80%E6%AD%A5%EF%BC%9A%E5%BC%80%E4%B8%80%E4%B8%AAstring.h%E7%9A%84%E5%A4%B4%E6%96%87%E4%BB%B6\">\u7b2c\u4e00\u6b65&#xff1a;\u5f00\u4e00\u4e2astring.h\u7684\u5934\u6587\u4ef6<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"873\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260213150521-698f3db1a6999.png\" width=\"2441\" \/><\/p>\n<h4 id=\"1.%20%E4%BB%A3%E7%A0%81%E7%BB%93%E6%9E%84%E5%88%86%E6%9E%90\">1. \u4ee3\u7801\u7ed3\u6784\u5206\u6790<\/h4>\n<p>#pragma once<br \/>\n#include &lt;iostream&gt;<br \/>\n#include &lt;assert.h&gt;<br \/>\nusing namespace std;<\/p>\n<p>namespace bit<br \/>\n{<br \/>\n    class string<br \/>\n    {<br \/>\n    private:<br \/>\n        char* _str &#061; nullptr;   \/\/ \u6307\u5411\u5806\u4e0a\u7684\u5b57\u7b26\u6570\u7ec4<br \/>\n        size_t _size &#061; 0;       \/\/ \u5f53\u524d\u6709\u6548\u5b57\u7b26\u4e2a\u6570&#xff08;\u4e0d\u542b&#039;\\\\0&#039;&#xff09;<br \/>\n        size_t _capacity &#061; 0;   \/\/ \u5f53\u524d\u53ef\u5b58\u50a8\u7684\u6700\u5927\u5b57\u7b26\u6570&#xff08;\u4e0d\u542b&#039;\\\\0&#039;&#xff09;<br \/>\n    };<br \/>\n}<\/p>\n<ul>\n<li>_str&#xff1a;\u6307\u5411\u52a8\u6001\u5206\u914d\u7684\u5b57\u7b26\u6570\u7ec4&#xff0c;\u662f\u5b57\u7b26\u4e32\u7684\u5b9e\u9645\u5b58\u50a8\u4f4d\u7f6e\u3002<\/li>\n<li>_size&#xff1a;\u8bb0\u5f55\u5f53\u524d\u5b57\u7b26\u4e32\u7684\u6709\u6548\u957f\u5ea6&#xff0c;\u907f\u514d\u6bcf\u6b21\u90fd\u8c03\u7528 strlen \u8ba1\u7b97\u3002<\/li>\n<li>_capacity&#xff1a;\u8bb0\u5f55\u5f53\u524d\u5206\u914d\u7684\u5185\u5b58\u5bb9\u91cf&#xff0c;\u7528\u4e8e\u5b9e\u73b0\u52a8\u6001\u6269\u5bb9&#xff0c;\u907f\u514d\u9891\u7e41\u5206\u914d\u5185\u5b58\u3002<\/li>\n<li>\u4f7f\u7528 namespace bit\u00a0&#xff0c;\u53ef\u4ee5\u907f\u514d\u4e0e\u6807\u51c6\u5e93 std::string \u51b2\u7a81\u3002<\/li>\n<\/ul>\n<hr \/>\n<p>\u57fa\u4e8e\u8fd9\u4e2a\u6846\u67b6&#xff0c;\u53ef\u4ee5\u9010\u6b65\u5b9e\u73b0\u4ee5\u4e0b\u6838\u5fc3\u529f\u80fd&#xff1a;<\/p>\n<li>\n<p>\u6784\u9020\u51fd\u6570&#xff1a;<\/p>\n<ul>\n<li>\u9ed8\u8ba4\u6784\u9020&#xff1a;string()<\/li>\n<li>\u4ece C \u5b57\u7b26\u4e32\u6784\u9020&#xff1a;string(const char* s)<\/li>\n<li>\u62f7\u8d1d\u6784\u9020&#xff1a;string(const string&amp; s)<\/li>\n<li>\u79fb\u52a8\u6784\u9020&#xff1a;string(string&amp;&amp; s)<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u6790\u6784\u51fd\u6570&#xff1a;<\/p>\n<ul>\n<li>\u91ca\u653e _str \u6307\u5411\u7684\u5806\u5185\u5b58&#xff0c;\u907f\u514d\u5185\u5b58\u6cc4\u6f0f\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u8fd0\u7b97\u7b26\u91cd\u8f7d&#xff1a;<\/p>\n<ul>\n<li>\u62f7\u8d1d\u8d4b\u503c&#xff1a;string&amp; operator&#061;(const string&amp; s)<\/li>\n<li>\u79fb\u52a8\u8d4b\u503c&#xff1a;string&amp; operator&#061;(string&amp;&amp; s)<\/li>\n<li>\u4e0b\u6807\u8bbf\u95ee&#xff1a;char&amp; operator[](size_t pos)<\/li>\n<li>\u6d41\u8f93\u51fa&#xff1a;friend ostream&amp; operator&lt;&lt;(ostream&amp; os, const string&amp; s)<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u5e38\u7528\u6210\u5458\u51fd\u6570&#xff1a;<\/p>\n<ul>\n<li>size() \/ length()&#xff1a;\u8fd4\u56de _size<\/li>\n<li>c_str()&#xff1a;\u8fd4\u56de _str<\/li>\n<li>push_back(char ch)&#xff1a;\u5728\u672b\u5c3e\u6dfb\u52a0\u5b57\u7b26<\/li>\n<li>append(const string&amp; s)&#xff1a;\u8ffd\u52a0\u5b57\u7b26\u4e32<\/li>\n<li>resize(size_t n) \/ reserve(size_t n)&#xff1a;\u8c03\u6574\u5927\u5c0f\u548c\u5bb9\u91cf<\/li>\n<\/ul>\n<\/li>\n<hr \/>\n<h3 id=\"1.%E6%9E%84%E9%80%A0%E5%87%BD%E6%95%B0%EF%BC%9A\">1.\u6784\u9020\u51fd\u6570&#xff1a;<\/h3>\n<h4 id=\"%C2%A0%20%C2%A0%20%C2%A0%20%C2%A0%20%E6%B5%85%E6%8B%B7%E8%B4%9D%EF%BC%9A\">\u00a0 \u00a0 \u00a0 \u00a0 \u6d45\u62f7\u8d1d&#xff1a;<\/h4>\n<p>\/*string()<br \/>\n:_str(new char[1]{&#039;\\\\0&#039;})<br \/>\n,_size(0)<br \/>\n,_capacity(0)<br \/>\n{}*\/<\/p>\n<p>\/\/ \u77ed\u5c0f\u9891\u7e41\u8c03\u7528\u7684\u51fd\u6570&#xff0c;\u53ef\u4ee5\u76f4\u63a5\u5b9a\u4e49\u5230\u7c7b\u91cc\u9762&#xff0c;\u9ed8\u8ba4\u662finline<br \/>\n\/\/ \u4ee3\u66ffstring().\u4f18\u5316\u5199\u6cd5<br \/>\nstring(const char* str &#061; &#034;&#034;)  \/\/ &#034; &#034;\u4e2d\u95f4\u9ed8\u8ba4\u662f\\\\0<br \/>\n{<br \/>\n_size &#061; strlen(str);<br \/>\n\/\/ _capacity\u4e0d\u5305\u542b\\\\0<br \/>\n_capacity &#061; _size;<br \/>\n_str &#061; new char[_capacity &#043; 1]; \/\/ \u9700\u8981\u989d\u5916\u5f00\u4e00\u4e2a\u7a7a\u95f4\u5b58\u653e&#034;\\\\0&#034;<br \/>\nstrcpy(_str, str);<br \/>\n} <\/p>\n<h4 id=\"%C2%A0%20%C2%A0%20%C2%A0%20%C2%A0%20%E6%B7%B1%E6%8B%B7%E8%B4%9D%EF%BC%9A\">\u00a0 \u00a0 \u00a0 \u00a0 \u6df1\u62f7\u8d1d&#xff1a;<\/h4>\n<p>\/\/ \u6df1\u62f7\u8d1d\u95ee\u9898<br \/>\n\/\/ s2(s1)<br \/>\n\/*string(const string&amp; s)<br \/>\n{<br \/>\n_str &#061; new char[s._capacity &#043; 1];<br \/>\nstrcpy(_str, s._str);<br \/>\n_size &#061; s._size;<br \/>\n_capacity &#061; s._capacity;<br \/>\n}*\/<\/p>\n<p>\/\/\u4f18\u5316\u5199\u6cd5<br \/>\n\/\/ \u8f85\u52a9\u51fd\u6570&#xff1a;\u4ea4\u6362\u4e24\u4e2a\u5bf9\u8c61\u7684\u6240\u6709\u8d44\u6e90<br \/>\nvoid swap(string&amp; s)<br \/>\n{<br \/>\n    std::swap(_str, s._str);<br \/>\n    std::swap(_size, s._size);<br \/>\n    std::swap(_capacity, s._capacity);<br \/>\n}<\/p>\n<p>\/\/ \u62f7\u8d1d\u6784\u9020\u51fd\u6570&#xff08;\u73b0\u4ee3\u5199\u6cd5&#xff09;<br \/>\nstring(const string&amp; s)<br \/>\n{<br \/>\n    string tmp(s._str); \/\/ 1. \u5148\u6784\u9020\u4e00\u4e2a\u4e34\u65f6\u5bf9\u8c61tmp&#xff0c;\u5b83\u662fs\u7684\u526f\u672c<br \/>\n    swap(tmp);          \/\/ 2. \u628a\u5f53\u524d\u5bf9\u8c61&#xff08;this&#xff09;\u548ctmp\u4ea4\u6362<br \/>\n} <\/p>\n<h5 id=\"%E6%A0%B8%E5%BF%83%E6%80%9D%E8%B7%AF%EF%BC%9A\">\u6838\u5fc3\u601d\u8def&#xff1a;<\/h5>\n<li>\u590d\u7528\u5df2\u6709\u6784\u9020\u51fd\u6570&#xff1a;\u5148\u5229\u7528\u5df2\u6709\u7684 string(const char*) \u6784\u9020\u51fd\u6570&#xff0c;\u521b\u5efa\u4e00\u4e2a\u4e34\u65f6\u5bf9\u8c61 tmp&#xff0c;\u5b83\u5df2\u7ecf\u662f s \u7684\u5b8c\u6574\u526f\u672c&#xff08;\u5305\u542b\u6b63\u786e\u7684\u5185\u5b58\u3001\u5927\u5c0f\u548c\u5bb9\u91cf&#xff09;\u3002<\/li>\n<li>\u4ea4\u6362\u8d44\u6e90&#xff1a;\u901a\u8fc7 swap \u51fd\u6570&#xff0c;\u628a\u5f53\u524d\u5bf9\u8c61&#xff08;this&#xff09;\u7684\u7a7a\u8d44\u6e90&#xff08;\u9ed8\u8ba4\u521d\u59cb\u5316\u7684 _str &#061; nullptr\u3001_size &#061; 0\u3001_capacity &#061; 0&#xff09;\u548c tmp \u7684\u6709\u6548\u8d44\u6e90\u4ea4\u6362\u3002<\/li>\n<li>\u81ea\u52a8\u6e05\u7406&#xff1a;\u5f53 tmp \u79bb\u5f00\u4f5c\u7528\u57df\u65f6&#xff0c;\u5b83\u7684\u6790\u6784\u51fd\u6570\u4f1a\u81ea\u52a8\u91ca\u653e\u6389\u539f\u6765 this \u6240\u6301\u6709\u7684\u7a7a\u8d44\u6e90&#xff0c;\u6574\u4e2a\u8fc7\u7a0b\u5b89\u5168\u4e14\u81ea\u52a8\u3002<\/li>\n<h5 id=\"%E4%BC%98%E5%8A%BF%EF%BC%9A\">\u4f18\u52bf&#xff1a;<\/h5>\n<ul>\n<li>\u4ee3\u7801\u6781\u7b80&#xff1a;\u590d\u7528\u4e86\u5df2\u6709\u6784\u9020\u51fd\u6570&#xff0c;\u907f\u514d\u4e86\u91cd\u590d\u7684\u5185\u5b58\u5206\u914d\u548c\u62f7\u8d1d\u903b\u8f91\u3002<\/li>\n<li>\u5f02\u5e38\u5b89\u5168&#xff1a;\u5982\u679c\u6784\u9020 tmp \u65f6\u629b\u51fa\u5f02\u5e38&#xff08;\u5982\u5185\u5b58\u4e0d\u8db3&#xff09;&#xff0c;\u5f53\u524d\u5bf9\u8c61 this \u4fdd\u6301\u521d\u59cb\u7684\u7a7a\u72b6\u6001&#xff0c;\u4e0d\u4f1a\u5904\u4e8e\u534a\u6784\u9020\u7684\u65e0\u6548\u72b6\u6001\u3002<\/li>\n<li><\/li>\n<\/ul>\n<h4 id=\"%E5%BB%B6%E4%BC%B8%EF%BC%9A%E6%8B%B7%E8%B4%9D%E8%B5%8B%E5%80%BC%E8%BF%90%E7%AE%97%E7%AC%A6%E4%B9%9F%E5%8F%AF%E4%BB%A5%E7%94%A8%E8%BF%99%E4%B8%AA%E5%86%99%E6%B3%95\">\u5ef6\u4f38&#xff1a;\u62f7\u8d1d\u8d4b\u503c\u8fd0\u7b97\u7b26\u4e5f\u53ef\u4ee5\u7528\u8fd9\u4e2a\u5199\u6cd5<\/h4>\n<p>\/\/ s1 &#061; s3;<br \/>\n\/\/string&amp; operator&#061;(const string&amp; s)<br \/>\n\/\/{<br \/>\n\/\/if (this !&#061; &amp;s)<br \/>\n\/\/{<br \/>\n\/\/\/\/string tmp(s._str);<br \/>\n\/\/string tmp(s);<br \/>\n\/\/swap(tmp);<br \/>\n\/\/}<br \/>\n\/\/return *this;<br \/>\n\/\/}<\/p>\n<p>\/\/ s1 &#061; s3;<br \/>\nstring&amp; operator&#061;(string tmp)\/\/ \u6ce8\u610f&#xff1a;\u53c2\u6570\u662f\u503c\u4f20\u9012&#xff0c;\u4f1a\u81ea\u52a8\u8c03\u7528\u62f7\u8d1d\u6784\u9020<br \/>\n{<br \/>\nswap(tmp);\/\/ \u76f4\u63a5\u548c\u4e34\u65f6\u5bf9\u8c61\u4ea4\u6362<br \/>\nreturn *this;<br \/>\n}<\/p>\n<ul>\n<li>\u53c2\u6570 s \u662f\u4e00\u4e2a\u503c\u4f20\u9012\u7684\u526f\u672c&#xff0c;\u51fd\u6570\u7ed3\u675f\u540e\u4f1a\u81ea\u52a8\u6790\u6784&#xff0c;\u91ca\u653e\u6389 this \u539f\u6765\u7684\u65e7\u8d44\u6e90\u3002<\/li>\n<li>\u8fd9\u662f C&#043;&#043; \u4e2d\u5b9e\u73b0\u5f3a\u5f02\u5e38\u5b89\u5168\u62f7\u8d1d\u8d4b\u503c\u7684\u7ecf\u5178\u65b9\u6848\u3002<\/li>\n<\/ul>\n<hr \/>\n<h3 id=\"2.%E6%9E%90%E6%9E%84%E5%87%BD%E6%95%B0%EF%BC%9A\">2.\u6790\u6784\u51fd\u6570&#xff1a;<\/h3>\n<p>~string()<br \/>\n{<br \/>\nif (_str)<br \/>\n{<br \/>\ndelete[] _str;<br \/>\n_str &#061; nullptr;<br \/>\n_size &#061; _capacity &#061; 0;<br \/>\n}<br \/>\n} <\/p>\n<p>\u91ca\u653e _str \u6307\u5411\u7684\u5806\u5185\u5b58&#xff0c;\u907f\u514d\u5185\u5b58\u6cc4\u6f0f\u3002<\/p>\n<hr \/>\n<h3 id=\"3.%E5%B8%B8%E7%94%A8%E6%88%90%E5%91%98%E5%87%BD%E6%95%B0%EF%BC%9A\">3.\u5e38\u7528\u6210\u5458\u51fd\u6570&#xff1a;<\/h3>\n<h4 id=\"%C2%A0%20%C2%A0%20%C2%A0%20%C2%A0%201.iterator%EF%BC%88%E8%BF%AD%E4%BB%A3%E5%99%A8%EF%BC%89\">\u00a0 \u00a0 \u00a0 \u00a0 1.iterator&#xff08;\u8fed\u4ee3\u5668&#xff09;<\/h4>\n<p>public:<br \/>\ntypedef char* iterator;<br \/>\ntypedef const char* const_iterator;<\/p>\n<p>iterator begin()<br \/>\n{<br \/>\nreturn _str;<br \/>\n}<\/p>\n<p>iterator end()<br \/>\n{<br \/>\nreturn _str &#043; _size;<br \/>\n}<\/p>\n<p>const_iterator begin() const<br \/>\n{<br \/>\nreturn _str;<br \/>\n}<\/p>\n<p>const_iterator end() const<br \/>\n{<br \/>\nreturn _str &#043; _size;<br \/>\n} <\/p>\n<h4 id=\"%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A02.%E5%B8%B8%E8%B0%83%E7%94%A8%E7%9A%84%E5%87%BD%E6%95%B0%E6%88%96%E7%AE%80%E5%8D%95%E7%9A%84%E5%87%BD%E6%95%B0\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a02.\u5e38\u8c03\u7528\u7684\u51fd\u6570\u6216\u7b80\u5355\u7684\u51fd\u6570<\/h4>\n<p>\/\/\u6ce8\u610f&#xff1a;\u4ee5\u4e0b\u90fd\u662f\u6210\u5458\u51fd\u6570&#xff0c;\u5728class string {} \u5185\u90e8<br \/>\n\/\/\u82e5string s1,\u4ee5\u4e0b\u662f\u7528\u6cd5  s1.\u6210\u5458\u51fd\u6570();<\/p>\n<p>\/\/s1.c_str;<\/p>\n<p>const char* c_str() const<br \/>\n{<br \/>\nreturn _str;<br \/>\n}<\/p>\n<p>\/\/s1.clear();<br \/>\nvoid clear()<br \/>\n{<br \/>\n_str[0] &#061; &#039;\\\\0&#039;;<br \/>\n_size &#061; 0;<br \/>\n}<\/p>\n<p>\/\/s1.size();<br \/>\nsize_t size() const<br \/>\n{<br \/>\nreturn _size;<br \/>\n}<\/p>\n<p>size_t capacity() const<br \/>\n{<br \/>\nreturn _capacity;<br \/>\n}<\/p>\n<p>char&amp; operator[](size_t pos)<br \/>\n{<br \/>\nassert(pos &lt; _size);<\/p>\n<p>return _str[pos];<br \/>\n}<\/p>\n<p>const char&amp; operator[](size_t pos) const<br \/>\n{<br \/>\nassert(pos &lt; _size);<\/p>\n<p>return _str[pos];<br \/>\n} <\/p>\n<p>\u5bf9\u4e8e\u5e38\u8c03\u7528\u7684\u51fd\u6570\u6216\u7b80\u5355\u7684\u51fd\u6570&#xff0c;\u53ef\u4ee5\u76f4\u63a5\u5728\u5934\u6587\u4ef6\u4e2d\u5b9a\u4e49<\/p>\n<p><span style=\"color:#a2e043\">\u77ed\u5c0f\u9891\u7e41\u8c03\u7528\u7684\u51fd\u6570&#xff0c;\u53ef\u4ee5\u76f4\u63a5\u5b9a\u4e49\u5230\u7c7b\u91cc\u9762&#xff0c;\u9ed8\u8ba4\u662finline<\/span><\/p>\n<h5 id=\"%E8%A1%A5%E5%85%85%EF%BC%9A\">\u8865\u5145&#xff1a;<\/h5>\n<p>\u5185\u8054\u51fd\u6570\u4e0e\u5934\u6587\u4ef6\u5b9a\u4e49<\/p>\n<p>\u5728\u5934\u6587\u4ef6\u4e2d\u76f4\u63a5\u5b9a\u4e49\u7b80\u5355\u51fd\u6570\u65f6&#xff0c;\u901a\u5e38\u4f1a\u4f7f\u7528inline\u5173\u952e\u5b57\u6765\u907f\u514d\u591a\u91cd\u5b9a\u4e49\u9519\u8bef\u3002\u5185\u8054\u51fd\u6570\u5efa\u8bae\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6&#xff1a;<\/p>\n<ul>\n<li>\u51fd\u6570\u4f53\u7b80\u77ed&#xff08;\u901a\u5e38\u4e0d\u8d85\u8fc710\u884c&#xff09;<\/li>\n<li>\u8c03\u7528\u9891\u7387\u9ad8<\/li>\n<li>\u4e0d\u542b\u9012\u5f52\u6216\u590d\u6742\u63a7\u5236\u6d41<\/li>\n<\/ul>\n<hr \/>\n<h3 id=\"4.%E8%BE%83%E5%A4%8D%E6%9D%82%E7%9A%84%E6%88%90%E5%91%98%E5%87%BD%E6%95%B0%C2%A0%20%C2%A0string.cpp\">4.\u8f83\u590d\u6742\u7684\u6210\u5458\u51fd\u6570\u00a0 \u00a0string.cpp<\/h3>\n<p>\u53ea\u58f0\u660e\u4e0d\u5b9e\u73b0&#xff1a;\u590d\u6742\u51fd\u6570\u7684\u5b9e\u73b0\u5168\u90e8\u653e\u5728<span style=\"color:#a2e043\"> <\/span><span style=\"color:#fe2c24\">.cpp<\/span> \u6587\u4ef6\u4e2d&#xff0c;\u5934\u6587\u4ef6\u53ea\u4fdd\u7559\u58f0\u660e&#xff0c;\u51cf\u5c11\u7f16\u8bd1\u4f9d\u8d56&#xff1b;<\/p>\n<p>\/\/string.h<\/p>\n<p>void reserve(size_t n);<br \/>\nvoid push_back(char ch);<br \/>\nvoid append(const char* str);<br \/>\nstring&amp; operator&#043;&#061;(char ch);<br \/>\nstring&amp; operator&#043;&#061;(const char* str);<\/p>\n<p>void insert(size_t pos, char ch);<br \/>\nvoid insert(size_t pos, const char* str);<br \/>\nvoid erase(size_t pos, size_t len &#061; npos);<\/p>\n<p>size_t find(char ch, size_t pos &#061; 0);<br \/>\nsize_t find(const char* str, size_t pos &#061; 0);<br \/>\nstring substr(size_t pos &#061; 0, size_t len &#061; npos); <\/p>\n<h4 id=\"1.%E5%AE%9E%E7%8E%B0%EF%BC%8C%E6%97%A0%E6%B3%A8%E9%87%8A%E7%89%88%EF%BC%9A\">1.\u5b9e\u73b0&#xff0c;\u65e0\u6ce8\u91ca\u7248&#xff1a;<\/h4>\n<p>\u8fd9\u91cc\u8981\u6ce8\u610f&#xff1a;\u5728string.h\u4e2d\u6709\u9ed8\u8ba4\u53c2\u6570&#xff0c;\u5728string.cpp\u4e2d\u4e0d\u8981\u518d\u5199\u3002\u5982\u4e0b\u6587\u7684 find.<\/p>\n<p>#include&#034;string.h&#034;<\/p>\n<p>namespace bit<br \/>\n{<br \/>\nconst size_t string::npos &#061; -1;<\/p>\n<p>void string::reserve(size_t n)<br \/>\n{<br \/>\nif (n &gt; _capacity)<br \/>\n{<br \/>\n\/\/cout &lt;&lt; &#034;reserve:&#034; &lt;&lt; n &lt;&lt; endl;<\/p>\n<p>char* tmp &#061; new char[n &#043; 1];<br \/>\nstrcpy(tmp, _str);<br \/>\ndelete[] _str;<br \/>\n_str &#061; tmp;<br \/>\n_capacity &#061; n;<br \/>\n}<br \/>\n}<\/p>\n<p>void string::push_back(char ch)<br \/>\n{<br \/>\nif (_size &#061;&#061; _capacity)<br \/>\n{<br \/>\nreserve(_capacity &#061;&#061; 0 ? 4 : _capacity * 2);<br \/>\n}<\/p>\n<p>_str[_size] &#061; ch;<br \/>\n&#043;&#043;_size;<br \/>\n_str[_size] &#061; &#039;\\\\0&#039;;<br \/>\n}<\/p>\n<p>string&amp; string::operator&#043;&#061;(char ch)<br \/>\n{<br \/>\npush_back(ch);<br \/>\nreturn *this;<br \/>\n}<\/p>\n<p>void string::append(const char* str)<br \/>\n{<br \/>\nsize_t len &#061; strlen(str);<br \/>\nif (_size &#043; len &gt; _capacity)<br \/>\n{<br \/>\n\/\/ \u5927\u4e8e2\u500d&#xff0c;\u9700\u8981\u591a\u5c11\u5f00\u591a\u5c11&#xff0c;\u5c0f\u4e8e2\u500d\u63092\u500d\u6269<br \/>\nreserve(_size &#043; len &gt; 2 * _capacity ? _size &#043; len : 2 * _capacity);<br \/>\n}<\/p>\n<p>strcpy(_str &#043; _size, str);<br \/>\n_size &#043;&#061; len;<br \/>\n}<\/p>\n<p>string&amp; string::operator&#043;&#061;(const char* str)<br \/>\n{<br \/>\nappend(str);<br \/>\nreturn *this;<br \/>\n}<\/p>\n<p>void string::insert(size_t pos, char ch)<br \/>\n{<br \/>\nassert(pos &lt;&#061; _size);<\/p>\n<p>if (_size &#061;&#061; _capacity)<br \/>\n{<br \/>\nreserve(_capacity &#061;&#061; 0 ? 4 : _capacity * 2);<br \/>\n}<\/p>\n<p>\/\/ \u632a\u52a8\u6570\u636e<br \/>\nsize_t end &#061; _size &#043; 1;<br \/>\nwhile (end &gt; pos)<br \/>\n{<br \/>\n_str[end] &#061; _str[end &#8211; 1];<br \/>\n&#8211;end;<br \/>\n}<\/p>\n<p>_str[pos] &#061; ch;<br \/>\n&#043;&#043;_size;<br \/>\n}<\/p>\n<p>void string::insert(size_t pos, const char* s)<br \/>\n{<br \/>\nassert(pos &lt;&#061; _size);<\/p>\n<p>size_t len &#061; strlen(s);<br \/>\nif (_size &#043; len &gt; _capacity)<br \/>\n{<br \/>\n\/\/ \u5927\u4e8e2\u500d&#xff0c;\u9700\u8981\u591a\u5c11\u5f00\u591a\u5c11&#xff0c;\u5c0f\u4e8e2\u500d\u63092\u500d\u6269<br \/>\nreserve(_size &#043; len &gt; 2 * _capacity ? _size &#043; len : 2 * _capacity);<br \/>\n}<\/p>\n<p>size_t end &#061; _size &#043; len;<br \/>\nwhile (end &gt; pos &#043; len &#8211; 1)<br \/>\n{<br \/>\n_str[end] &#061; _str[end &#8211; len];<br \/>\n&#8211;end;<br \/>\n}<\/p>\n<p>for (size_t i &#061; 0; i &lt; len; i&#043;&#043;)<br \/>\n{<br \/>\n_str[pos &#043; i] &#061; s[i];<br \/>\n}<\/p>\n<p>_size &#043;&#061; len;<br \/>\n}<\/p>\n<p>void string::erase(size_t pos, size_t len)<br \/>\n{<br \/>\nassert(pos &lt; _size);<\/p>\n<p>if (len &gt;&#061; _size &#8211; pos)<br \/>\n{<br \/>\n_str[pos] &#061; &#039;\\\\0&#039;;<br \/>\n_size &#061; pos;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nfor (size_t i &#061; pos &#043; len; i &lt;&#061; _size; i&#043;&#043;)<br \/>\n{<br \/>\n_str[i &#8211; len] &#061; _str[i];<br \/>\n}<\/p>\n<p>_size -&#061; len;<br \/>\n}<br \/>\n}<\/p>\n<p>size_t string::find(char ch, size_t pos)<br \/>\n{<br \/>\nassert(pos &lt; _size);<\/p>\n<p>for (size_t i &#061; pos; i &lt; _size; i&#043;&#043;)<br \/>\n{<br \/>\nif (_str[i] &#061;&#061; ch)<br \/>\n{<br \/>\nreturn i;<br \/>\n}<br \/>\n}<\/p>\n<p>return npos;<br \/>\n}<\/p>\n<p>size_t string::find(const char* str, size_t pos)<br \/>\n{<br \/>\nassert(pos &lt; _size);<\/p>\n<p>const char* ptr &#061; strstr(_str &#043; pos, str);<br \/>\nif (ptr &#061;&#061; nullptr)<br \/>\n{<br \/>\nreturn npos;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nreturn ptr &#8211; _str;<br \/>\n}<br \/>\n}<\/p>\n<p>string string::substr(size_t pos, size_t len)<br \/>\n{<br \/>\nassert(pos &lt; _size);<\/p>\n<p>\/\/ len\u5927\u4e8e\u5269\u4f59\u5b57\u7b26\u957f\u5ea6&#xff0c;\u66f4\u65b0\u4e00\u4e0blen<br \/>\nif (len &gt; _size &#8211; pos)<br \/>\n{<br \/>\nlen &#061; _size &#8211; pos;<br \/>\n}<\/p>\n<p>string sub;<br \/>\nsub.reserve(len);<br \/>\nfor (size_t i &#061; 0; i &lt; len; i&#043;&#043;)<br \/>\n{<br \/>\nsub &#043;&#061; _str[pos &#043; i];<br \/>\n}<\/p>\n<p>return sub;<br \/>\n}<\/p>\n<h4 id=\"2.%E4%BB%A3%E7%A0%81%E6%B3%A8%E9%87%8A%E7%89%88\">2.\u4ee3\u7801\u6ce8\u91ca\u7248<\/h4>\n<p>#include&#034;string.h&#034;<\/p>\n<p>namespace bit<br \/>\n{<br \/>\n    \/\/ \u5b9a\u4e49\u9759\u6001\u6210\u5458npos&#xff0c;\u8868\u793a\u65e0\u6548\u4f4d\u7f6e\u6216\u672a\u627e\u5230<br \/>\n    const size_t string::npos &#061; -1;<\/p>\n<p>    \/\/ \u8c03\u6574\u5b57\u7b26\u4e32\u5bb9\u91cf\u81f3\u81f3\u5c11n\u4e2a\u5b57\u7b26&#xff08;\u4e0d\u5305\u62ec\u7ed3\u5c3e\u7684&#039;\\\\0&#039;&#xff09;<br \/>\n    void string::reserve(size_t n)<br \/>\n    {<br \/>\n        if (n &gt; _capacity)<br \/>\n        {<br \/>\n            \/\/ \u5206\u914d\u65b0\u5185\u5b58&#xff08;\u591a1\u5b57\u8282\u7528\u4e8e\u5b58\u50a8&#039;\\\\0&#039;&#xff09;<br \/>\n            char* tmp &#061; new char[n &#043; 1];<br \/>\n            \/\/ \u590d\u5236\u539f\u5185\u5bb9\u5230\u65b0\u5185\u5b58<br \/>\n            strcpy(tmp, _str);<br \/>\n            \/\/ \u91ca\u653e\u65e7\u5185\u5b58<br \/>\n            delete[] _str;<br \/>\n            _str &#061; tmp;<br \/>\n            _capacity &#061; n;<br \/>\n        }<br \/>\n    }<\/p>\n<p>    \/\/ \u5728\u5b57\u7b26\u4e32\u672b\u5c3e\u8ffd\u52a0\u5b57\u7b26<br \/>\n    void string::push_back(char ch)<br \/>\n    {<br \/>\n        \/\/ \u5bb9\u91cf\u4e0d\u8db3\u65f6\u6269\u5bb9&#xff08;\u521d\u59cb\u4e3a0\u5219\u6269\u5bb9\u81f34&#xff09;<br \/>\n        if (_size &#061;&#061; _capacity)<br \/>\n        {<br \/>\n            reserve(_capacity &#061;&#061; 0 ? 4 : _capacity * 2);<br \/>\n        }<\/p>\n<p>        \/\/ \u5199\u5165\u5b57\u7b26\u5e76\u66f4\u65b0\u5927\u5c0f\u548c\u7ed3\u5c3e&#039;\\\\0&#039;<br \/>\n        _str[_size] &#061; ch;<br \/>\n        &#043;&#043;_size;<br \/>\n        _str[_size] &#061; &#039;\\\\0&#039;;<br \/>\n    }<\/p>\n<p>    \/\/ \u91cd\u8f7d&#043;&#061;\u8fd0\u7b97\u7b26&#xff08;\u5b57\u7b26\u7248\u672c&#xff09;<br \/>\n    string&amp; string::operator&#043;&#061;(char ch)<br \/>\n    {<br \/>\n        push_back(ch);<br \/>\n        return *this;<br \/>\n    }<\/p>\n<p>    \/\/ \u8ffd\u52a0C\u98ce\u683c\u5b57\u7b26\u4e32<br \/>\n    void string::append(const char* str)<br \/>\n    {<br \/>\n        size_t len &#061; strlen(str);<br \/>\n        \/\/ \u5bb9\u91cf\u4e0d\u8db3\u65f6\u6269\u5bb9&#xff08;\u6309\u9700\u62162\u500d\u6269\u5bb9\u7b56\u7565&#xff09;<br \/>\n        if (_size &#043; len &gt; _capacity)<br \/>\n        {<br \/>\n            reserve(_size &#043; len &gt; 2 * _capacity ? _size &#043; len : 2 * _capacity);<br \/>\n        }<\/p>\n<p>        \/\/ \u8ffd\u52a0\u5185\u5bb9\u5e76\u66f4\u65b0\u5927\u5c0f<br \/>\n        strcpy(_str &#043; _size, str);<br \/>\n        _size &#043;&#061; len;<br \/>\n    }<\/p>\n<p>    \/\/ \u91cd\u8f7d&#043;&#061;\u8fd0\u7b97\u7b26&#xff08;\u5b57\u7b26\u4e32\u7248\u672c&#xff09;<br \/>\n    string&amp; string::operator&#043;&#061;(const char* str)<br \/>\n    {<br \/>\n        append(str);<br \/>\n        return *this;<br \/>\n    }<\/p>\n<p>    \/\/ \u5728\u6307\u5b9a\u4f4d\u7f6e\u63d2\u5165\u5b57\u7b26<br \/>\n    void string::insert(size_t pos, char ch)<br \/>\n    {<br \/>\n        assert(pos &lt;&#061; _size);<\/p>\n<p>        \/\/ \u5bb9\u91cf\u4e0d\u8db3\u65f6\u6269\u5bb9<br \/>\n        if (_size &#061;&#061; _capacity)<br \/>\n        {<br \/>\n            reserve(_capacity &#061;&#061; 0 ? 4 : _capacity * 2);<br \/>\n        }<\/p>\n<p>        \/\/ \u5411\u540e\u79fb\u52a8\u6570\u636e\u817e\u51fa\u4f4d\u7f6e<br \/>\n        size_t end &#061; _size &#043; 1;<br \/>\n        while (end &gt; pos)<br \/>\n        {<br \/>\n            _str[end] &#061; _str[end &#8211; 1];<br \/>\n            &#8211;end;<br \/>\n        }<\/p>\n<p>        \/\/ \u63d2\u5165\u5b57\u7b26\u5e76\u66f4\u65b0\u5927\u5c0f<br \/>\n        _str[pos] &#061; ch;<br \/>\n        &#043;&#043;_size;<br \/>\n    }<\/p>\n<p>    \/\/ \u5728\u6307\u5b9a\u4f4d\u7f6e\u63d2\u5165C\u98ce\u683c\u5b57\u7b26\u4e32<br \/>\n    void string::insert(size_t pos, const char* s)<br \/>\n    {<br \/>\n        assert(pos &lt;&#061; _size);<\/p>\n<p>        size_t len &#061; strlen(s);<br \/>\n        \/\/ \u5bb9\u91cf\u4e0d\u8db3\u65f6\u6269\u5bb9<br \/>\n        if (_size &#043; len &gt; _capacity)<br \/>\n        {<br \/>\n            reserve(_size &#043; len &gt; 2 * _capacity ? _size &#043; len : 2 * _capacity);<br \/>\n        }<\/p>\n<p>        \/\/ \u79fb\u52a8\u539f\u6709\u6570\u636e<br \/>\n        size_t end &#061; _size &#043; len;<br \/>\n        while (end &gt; pos &#043; len &#8211; 1)<br \/>\n        {<br \/>\n            _str[end] &#061; _str[end &#8211; len];<br \/>\n            &#8211;end;<br \/>\n        }<\/p>\n<p>        \/\/ \u63d2\u5165\u65b0\u5b57\u7b26\u4e32\u5185\u5bb9<br \/>\n        for (size_t i &#061; 0; i &lt; len; i&#043;&#043;)<br \/>\n        {<br \/>\n            _str[pos &#043; i] &#061; s[i];<br \/>\n        }<\/p>\n<p>        _size &#043;&#061; len;<br \/>\n    }<\/p>\n<p>    \/\/ \u5220\u9664\u4ecepos\u5f00\u59cb\u7684len\u4e2a\u5b57\u7b26<br \/>\n    void string::erase(size_t pos, size_t len)<br \/>\n    {<br \/>\n        assert(pos &lt; _size);<\/p>\n<p>        \/\/ \u82e5\u5220\u9664\u8303\u56f4\u8d85\u8fc7\u5b57\u7b26\u4e32\u5c3e\u90e8&#xff0c;\u5219\u622a\u65ad\u5230pos\u4f4d\u7f6e<br \/>\n        if (len &gt;&#061; _size &#8211; pos)<br \/>\n        {<br \/>\n            _str[pos] &#061; &#039;\\\\0&#039;;<br \/>\n            _size &#061; pos;<br \/>\n        }<br \/>\n        else<br \/>\n        {<br \/>\n            \/\/ \u5411\u524d\u79fb\u52a8\u5269\u4f59\u5b57\u7b26\u8986\u76d6\u88ab\u5220\u9664\u90e8\u5206<br \/>\n            for (size_t i &#061; pos &#043; len; i &lt;&#061; _size; i&#043;&#043;)<br \/>\n            {<br \/>\n                _str[i &#8211; len] &#061; _str[i];<br \/>\n            }<br \/>\n            _size -&#061; len;<br \/>\n        }<br \/>\n    }<\/p>\n<p>    \/\/ \u4ecepos\u4f4d\u7f6e\u5f00\u59cb\u67e5\u627e\u5b57\u7b26ch<br \/>\n    size_t string::find(char ch, size_t pos)<br \/>\n    {<br \/>\n        assert(pos &lt; _size);<\/p>\n<p>        \/\/ \u7ebf\u6027\u641c\u7d22\u5339\u914d\u5b57\u7b26<br \/>\n        for (size_t i &#061; pos; i &lt; _size; i&#043;&#043;)<br \/>\n        {<br \/>\n            if (_str[i] &#061;&#061; ch)<br \/>\n            {<br \/>\n                return i;<br \/>\n            }<br \/>\n        }<\/p>\n<p>        return npos;<br \/>\n    }<\/p>\n<p>    \/\/ \u4ecepos\u4f4d\u7f6e\u5f00\u59cb\u67e5\u627e\u5b50\u4e32str<br \/>\n    size_t string::find(const char* str, size_t pos)<br \/>\n    {<br \/>\n        assert(pos &lt; _size);<\/p>\n<p>        \/\/ \u4f7f\u7528strstr\u51fd\u6570\u67e5\u627e\u5b50\u4e32<br \/>\n        const char* ptr &#061; strstr(_str &#043; pos, str);<br \/>\n        if (ptr &#061;&#061; nullptr)<br \/>\n        {<br \/>\n            return npos;<br \/>\n        }<br \/>\n        else<br \/>\n        {<br \/>\n            return ptr &#8211; _str;<br \/>\n        }<br \/>\n    }<\/p>\n<p>    \/\/ \u63d0\u53d6\u4ecepos\u5f00\u59cb\u957f\u5ea6\u4e3alen\u7684\u5b50\u4e32<br \/>\n    string string::substr(size_t pos, size_t len)<br \/>\n    {<br \/>\n        assert(pos &lt; _size);<\/p>\n<p>        \/\/ \u8c03\u6574len\u4e0d\u8d85\u8fc7\u5269\u4f59\u5b57\u7b26\u6570<br \/>\n        if (len &gt; _size &#8211; pos)<br \/>\n        {<br \/>\n            len &#061; _size &#8211; pos;<br \/>\n        }<\/p>\n<p>        \/\/ \u521b\u5efa\u5b50\u4e32\u5bf9\u8c61\u5e76\u9884\u5206\u914d\u7a7a\u95f4<br \/>\n        string sub;<br \/>\n        sub.reserve(len);<br \/>\n        \/\/ \u9010\u4e2a\u5b57\u7b26\u590d\u5236<br \/>\n        for (size_t i &#061; 0; i &lt; len; i&#043;&#043;)<br \/>\n        {<br \/>\n            sub &#043;&#061; _str[pos &#043; i];<br \/>\n        }<\/p>\n<p>        return sub;<br \/>\n    }<br \/>\n}<\/p>\n<hr \/>\n<h3 id=\"5.%E8%BF%90%E7%AE%97%E7%AC%A6%E9%87%8D%E8%BD%BD%E5%AE%9E%E7%8E%B0%E5%AD%97%E7%AC%A6%E4%B8%B2%E6%AF%94%E8%BE%83%E5%92%8C%E8%BE%93%E5%85%A5%E8%BE%93%E5%87%BA%E5%8A%9F%E8%83%BD\">5.\u8fd0\u7b97\u7b26\u91cd\u8f7d\u5b9e\u73b0\u5b57\u7b26\u4e32\u6bd4\u8f83\u548c\u8f93\u5165\u8f93\u51fa\u529f\u80fd<\/h3>\n<p>#pragma once<br \/>\n#include&lt;iostream&gt;<br \/>\n#include&lt;assert.h&gt;<br \/>\nusing namespace std;<\/p>\n<p>namespace bit<br \/>\n{<br \/>\nclass string<br \/>\n{<br \/>\n\/\/&#8230;&#8230;<\/p>\n<p>};<\/p>\n<p>bool operator&lt;(const string&amp; s1, const string&amp; s2);<br \/>\nbool operator&lt;&#061;(const string&amp; s1, const string&amp; s2);<br \/>\nbool operator&gt;(const string&amp; s1, const string&amp; s2);<br \/>\nbool operator&gt;&#061;(const string&amp; s1, const string&amp; s2);<br \/>\nbool operator&#061;&#061;(const string&amp; s1, const string&amp; s2);<br \/>\nbool operator!&#061;(const string&amp; s1, const string&amp; s2);<\/p>\n<p>ostream&amp; operator&lt;&lt;(ostream&amp; out, const string&amp; s);<br \/>\nistream&amp; operator&gt;&gt;(istream&amp; in, string&amp; s);<br \/>\n} <\/p>\n<h4 id=\"\"><\/h4>\n<h5 id=\"1.%E6%AF%94%E8%BE%83%E8%BF%90%E7%AE%97%E7%AC%A6%E9%87%8D%E8%BD%BD\">1.\u6bd4\u8f83\u8fd0\u7b97\u7b26\u91cd\u8f7d<\/h5>\n<p>bool operator&lt;(const string&amp; s1, const string&amp; s2)<br \/>\n{<br \/>\n    \/\/ \u4f7f\u7528strcmp\u6bd4\u8f83\u4e24\u4e2a\u5b57\u7b26\u4e32\u7684C\u98ce\u683c\u5b57\u7b26\u4e32\u5f62\u5f0f<br \/>\n    \/\/ \u8fd4\u56des1\u662f\u5426\u6309\u5b57\u5178\u5e8f\u5c0f\u4e8es2<br \/>\n    return strcmp(s1.c_str(), s2.c_str()) &lt; 0;<br \/>\n}<\/p>\n<p>bool operator&lt;&#061;(const string&amp; s1, const string&amp; s2)<br \/>\n{<br \/>\n    \/\/ \u5c0f\u4e8e\u6216\u7b49\u4e8e\u8fd0\u7b97\u901a\u8fc7\u7ec4\u5408&lt;\u548c&#061;&#061;\u8fd0\u7b97\u7b26\u5b9e\u73b0<br \/>\n    return s1 &lt; s2 || s1 &#061;&#061; s2;<br \/>\n}<\/p>\n<p>bool operator&gt;(const string&amp; s1, const string&amp; s2)<br \/>\n{<br \/>\n    \/\/ \u5927\u4e8e\u8fd0\u7b97\u901a\u8fc7\u5426\u5b9a&lt;&#061;\u8fd0\u7b97\u5b9e\u73b0<br \/>\n    return !(s1 &lt;&#061; s2);<br \/>\n}<\/p>\n<p>bool operator&gt;&#061;(const string&amp; s1, const string&amp; s2)<br \/>\n{<br \/>\n    \/\/ \u5927\u4e8e\u7b49\u4e8e\u8fd0\u7b97\u901a\u8fc7\u5426\u5b9a&lt;\u8fd0\u7b97\u5b9e\u73b0<br \/>\n    return !(s1 &lt; s2);<br \/>\n}<\/p>\n<p>bool operator&#061;&#061;(const string&amp; s1, const string&amp; s2)<br \/>\n{<br \/>\n    \/\/ \u76f8\u7b49\u8fd0\u7b97\u4f7f\u7528strcmp\u6bd4\u8f83C\u98ce\u683c\u5b57\u7b26\u4e32<br \/>\n    return strcmp(s1.c_str(), s2.c_str()) &#061;&#061; 0;<br \/>\n}<\/p>\n<p>bool operator!&#061;(const string&amp; s1, const string&amp; s2)<br \/>\n{<br \/>\n    \/\/ \u4e0d\u7b49\u8fd0\u7b97\u901a\u8fc7\u5426\u5b9a&#061;&#061;\u8fd0\u7b97\u5b9e\u73b0<br \/>\n    return !(s1 &#061;&#061; s2);<br \/>\n}<\/p>\n<h5 id=\"2.%E6%B5%81%E8%BF%90%E7%AE%97%E7%AC%A6%E9%87%8D%E8%BD%BD\">2.\u6d41\u8fd0\u7b97\u7b26\u91cd\u8f7d<\/h5>\n<p>ostream&amp; operator&lt;&lt;(ostream&amp; out, const string&amp; s)<br \/>\n{<br \/>\n    \/\/ \u904d\u5386\u5b57\u7b26\u4e32\u7684\u6bcf\u4e2a\u5b57\u7b26\u5e76\u8f93\u51fa\u5230\u8f93\u51fa\u6d41<br \/>\n    for (auto ch : s)<br \/>\n    {<br \/>\n        out &lt;&lt; ch;<br \/>\n    }<br \/>\n    return out;  \/\/ \u8fd4\u56de\u8f93\u51fa\u6d41\u4ee5\u652f\u6301\u94fe\u5f0f\u8c03\u7528<br \/>\n}<\/p>\n<p>istream&amp; operator&gt;&gt;(istream&amp; in, string&amp; s)<br \/>\n{<br \/>\n    s.clear();  \/\/ \u6e05\u7a7a\u76ee\u6807\u5b57\u7b26\u4e32<\/p>\n<p>    const int N &#061; 256;  \/\/ \u7f13\u51b2\u533a\u5927\u5c0f<br \/>\n    char buff[N];       \/\/ \u5b57\u7b26\u7f13\u51b2\u533a<br \/>\n    int i &#061; 0;          \/\/ \u7f13\u51b2\u533a\u7d22\u5f15<\/p>\n<p>    char ch;<br \/>\n    ch &#061; in.get();  \/\/ \u4f7f\u7528get()\u8bfb\u53d6\u5355\u4e2a\u5b57\u7b26&#xff08;\u5305\u62ec\u7a7a\u683c&#xff09;<\/p>\n<p>    \/\/ \u8bfb\u53d6\u76f4\u5230\u9047\u5230\u7a7a\u683c\u6216\u6362\u884c\u7b26<br \/>\n    while (ch !&#061; &#039; &#039; &amp;&amp; ch !&#061; &#039;\\\\n&#039;)<br \/>\n    {<br \/>\n        buff[i&#043;&#043;] &#061; ch;<\/p>\n<p>        \/\/ \u7f13\u51b2\u533a\u6ee1\u65f6\u5904\u7406<br \/>\n        if (i &#061;&#061; N &#8211; 1)<br \/>\n        {<br \/>\n            buff[i] &#061; &#039;\\\\0&#039;;  \/\/ \u6dfb\u52a0\u5b57\u7b26\u4e32\u7ed3\u675f\u7b26<br \/>\n            s &#043;&#061; buff;       \/\/ \u5c06\u7f13\u51b2\u533a\u5185\u5bb9\u8ffd\u52a0\u5230\u5b57\u7b26\u4e32<\/p>\n<p>            i &#061; 0;           \/\/ \u91cd\u7f6e\u7f13\u51b2\u533a\u7d22\u5f15<br \/>\n        }<\/p>\n<p>        ch &#061; in.get();  \/\/ \u8bfb\u53d6\u4e0b\u4e00\u4e2a\u5b57\u7b26<br \/>\n    }<\/p>\n<p>    \/\/ \u5904\u7406\u7f13\u51b2\u533a\u5269\u4f59\u5185\u5bb9<br \/>\n    if (i &gt; 0)<br \/>\n    {<br \/>\n        buff[i] &#061; &#039;\\\\0&#039;;<br \/>\n        s &#043;&#061; buff;<br \/>\n    }<\/p>\n<p>    return in;  \/\/ \u8fd4\u56de\u8f93\u5165\u6d41\u4ee5\u652f\u6301\u94fe\u5f0f\u8c03\u7528<br \/>\n}<\/p>\n<h4 id=\"%E5%85%B3%E9%94%AE%E5%AE%9E%E7%8E%B0%E7%BB%86%E8%8A%82%E8%AF%B4%E6%98%8E\">\u5173\u952e\u5b9e\u73b0\u7ec6\u8282\u8bf4\u660e<\/h4>\n<p>\u6bd4\u8f83\u8fd0\u7b97\u7b26\u5b9e\u73b0\u7279\u70b9 \u6240\u6709\u6bd4\u8f83\u8fd0\u7b97\u7b26\u90fd\u57fa\u4e8estrcmp\u51fd\u6570\u5b9e\u73b0&#xff0c;\u786e\u4fdd\u4e0eC\u98ce\u683c\u5b57\u7b26\u4e32\u6bd4\u8f83\u884c\u4e3a\u4e00\u81f4\u3002\u901a\u8fc7\u8fd0\u7b97\u7b26\u95f4\u7684\u903b\u8f91\u7ec4\u5408\u51cf\u5c11\u91cd\u590d\u4ee3\u7801&#xff0c;\u5982&gt;\u548c&gt;&#061;\u5206\u522b\u901a\u8fc7\u5426\u5b9a&lt;&#061;\u548c&lt;\u5b9e\u73b0\u3002<\/p>\n<p>\u6d41\u8fd0\u7b97\u7b26\u5b9e\u73b0\u7279\u70b9 \u8f93\u51fa\u8fd0\u7b97\u7b26\u76f4\u63a5\u904d\u5386\u5b57\u7b26\u4e32\u5b57\u7b26&#xff0c;\u7b80\u5355\u9ad8\u6548\u3002\u8f93\u5165\u8fd0\u7b97\u7b26\u91c7\u7528\u7f13\u51b2\u6280\u672f\u5904\u7406\u957f\u5b57\u7b26\u4e32&#xff0c;\u907f\u514d\u9891\u7e41\u5185\u5b58\u5206\u914d\u3002\u4f7f\u7528get()\u800c\u975e&gt;&gt;\u8bfb\u53d6\u5b57\u7b26&#xff0c;\u786e\u4fdd\u80fd\u6355\u83b7\u7a7a\u683c\u5b57\u7b26\u4f5c\u4e3a\u8f93\u5165\u7ec8\u6b62\u7b26\u3002<\/p>\n<p>\u7f13\u51b2\u533a\u7ba1\u7406 \u8f93\u5165\u8fd0\u7b97\u7b26\u4f7f\u7528\u56fa\u5b9a\u5927\u5c0f\u7f13\u51b2\u533a(256\u5b57\u8282)\u5206\u6279\u5904\u7406\u8f93\u5165&#xff0c;\u5e73\u8861\u5185\u5b58\u4f7f\u7528\u548c\u6027\u80fd\u3002\u5f53\u7f13\u51b2\u533a\u63a5\u8fd1\u6ee1\u65f6\u53ca\u65f6\u6e05\u7a7a&#xff0c;\u9632\u6b62\u6ea2\u51fa\u540c\u65f6\u51cf\u5c11\u5b57\u7b26\u4e32\u62fc\u63a5\u64cd\u4f5c\u3002<\/p>\n<hr \/>\n<h3 id=\"6.%E5%AE%8C%E6%95%B4%E4%BB%A3%E7%A0%81\">6.\u5b8c\u6574\u4ee3\u7801<\/h3>\n<h4 id=\"string.h\">string.h<\/h4>\n<p>#pragma once<br \/>\n#include&lt;iostream&gt;<br \/>\n#include&lt;assert.h&gt;<br \/>\nusing namespace std;<\/p>\n<p>namespace bit<br \/>\n{<br \/>\nclass string<br \/>\n{<br \/>\npublic:<br \/>\ntypedef char* iterator;<br \/>\ntypedef const char* const_iterator;<\/p>\n<p>iterator begin()<br \/>\n{<br \/>\nreturn _str;<br \/>\n}<\/p>\n<p>iterator end()<br \/>\n{<br \/>\nreturn _str &#043; _size;<br \/>\n}<\/p>\n<p>const_iterator begin() const<br \/>\n{<br \/>\nreturn _str;<br \/>\n}<\/p>\n<p>const_iterator end() const<br \/>\n{<br \/>\nreturn _str &#043; _size;<br \/>\n}<\/p>\n<p>\/*string()<br \/>\n:_str(new char[1]{&#039;\\\\0&#039;})<br \/>\n,_size(0)<br \/>\n,_capacity(0)<br \/>\n{}*\/<\/p>\n<p>\/\/ \u77ed\u5c0f\u9891\u7e41\u8c03\u7528\u7684\u51fd\u6570&#xff0c;\u53ef\u4ee5\u76f4\u63a5\u5b9a\u4e49\u5230\u7c7b\u91cc\u9762&#xff0c;\u9ed8\u8ba4\u662finline<br \/>\n\/\/\u4ee3\u66ffstring()<br \/>\nstring(const char* str &#061; &#034;&#034;)<br \/>\n{<br \/>\n_size &#061; strlen(str);<br \/>\n\/\/ _capacity\u4e0d\u5305\u542b\\\\0<br \/>\n_capacity &#061; _size;<br \/>\n_str &#061; new char[_capacity &#043; 1];<br \/>\nstrcpy(_str, str);<br \/>\n}<\/p>\n<p>\/\/ \u6df1\u62f7\u8d1d\u95ee\u9898<br \/>\n\/\/ s2(s1)<br \/>\n\/*string(const string&amp; s)<br \/>\n{<br \/>\n_str &#061; new char[s._capacity &#043; 1];<br \/>\nstrcpy(_str, s._str);<br \/>\n_size &#061; s._size;<br \/>\n_capacity &#061; s._capacity;<br \/>\n}*\/<\/p>\n<p>void swap(string&amp; s)<br \/>\n{<br \/>\nstd::swap(_str, s._str);<br \/>\nstd::swap(_size, s._size);<br \/>\nstd::swap(_capacity, s._capacity);<br \/>\n}<\/p>\n<p>\/\/ s2(s1)<br \/>\n\/\/ \u73b0\u4ee3\u5199\u6cd5<br \/>\nstring(const string&amp; s)<br \/>\n{<br \/>\nstring tmp(s._str);<br \/>\nswap(tmp);<br \/>\n}<\/p>\n<p>\/\/ s2 &#061; s1<br \/>\n\/\/ s1 &#061; s1<br \/>\n\/*string&amp; operator&#061;(const string&amp; s)<br \/>\n{<br \/>\nif (this !&#061; &amp;s)<br \/>\n{<br \/>\ndelete[] _str;<\/p>\n<p>_str &#061; new char[s._capacity &#043; 1];<br \/>\nstrcpy(_str, s._str);<br \/>\n_size &#061; s._size;<br \/>\n_capacity &#061; s._capacity;<br \/>\n}<\/p>\n<p>return *this;<br \/>\n}*\/<\/p>\n<p>\/\/ s1 &#061; s3;<br \/>\n\/\/string&amp; operator&#061;(const string&amp; s)<br \/>\n\/\/{<br \/>\n\/\/if (this !&#061; &amp;s)<br \/>\n\/\/{<br \/>\n\/\/\/\/string tmp(s._str);<br \/>\n\/\/string tmp(s);<\/p>\n<p>\/\/swap(tmp);<br \/>\n\/\/}<\/p>\n<p>\/\/return *this;<br \/>\n\/\/}<\/p>\n<p>\/\/ s1 &#061; s3;<br \/>\nstring&amp; operator&#061;(string tmp)<br \/>\n{<br \/>\nswap(tmp);<\/p>\n<p>return *this;<br \/>\n}<\/p>\n<p>~string()<br \/>\n{<br \/>\nif (_str)<br \/>\n{<br \/>\ndelete[] _str;<br \/>\n_str &#061; nullptr;<br \/>\n_size &#061; _capacity &#061; 0;<br \/>\n}<br \/>\n}<\/p>\n<p>const char* c_str() const<br \/>\n{<br \/>\nreturn _str;<br \/>\n}<\/p>\n<p>void clear()<br \/>\n{<br \/>\n_str[0] &#061; &#039;\\\\0&#039;;<br \/>\n_size &#061; 0;<br \/>\n}<\/p>\n<p>size_t size() const<br \/>\n{<br \/>\nreturn _size;<br \/>\n}<\/p>\n<p>size_t capacity() const<br \/>\n{<br \/>\nreturn _capacity;<br \/>\n}<\/p>\n<p>char&amp; operator[](size_t pos)<br \/>\n{<br \/>\nassert(pos &lt; _size);<\/p>\n<p>return _str[pos];<br \/>\n}<\/p>\n<p>const char&amp; operator[](size_t pos) const<br \/>\n{<br \/>\nassert(pos &lt; _size);<\/p>\n<p>return _str[pos];<br \/>\n}<\/p>\n<p>\/*void copy_on_write()<br \/>\n{<br \/>\nif (count &gt; 1)<br \/>\n{<br \/>\n\u6df1\u62f7\u8d1d<br \/>\n}<br \/>\n}*\/<\/p>\n<p>void reserve(size_t n);<br \/>\nvoid push_back(char ch);<br \/>\nvoid append(const char* str);<br \/>\nstring&amp; operator&#043;&#061;(char ch);<br \/>\nstring&amp; operator&#043;&#061;(const char* str);<\/p>\n<p>void insert(size_t pos, char ch);<br \/>\nvoid insert(size_t pos, const char* str);<br \/>\nvoid erase(size_t pos, size_t len &#061; npos);<\/p>\n<p>size_t find(char ch, size_t pos &#061; 0);<br \/>\nsize_t find(const char* str, size_t pos &#061; 0);<br \/>\nstring substr(size_t pos &#061; 0, size_t len &#061; npos);<br \/>\nprivate:<br \/>\n\/\/char _buff[16];<br \/>\nchar* _str &#061; nullptr;<br \/>\nsize_t _size &#061; 0;<br \/>\nsize_t _capacity &#061; 0;<\/p>\n<p>\/\/static const size_t npos &#061; -1;<br \/>\nstatic const size_t npos;<\/p>\n<p>\/*static const int N &#061; 10;<br \/>\nint buff[N];*\/<br \/>\n};<\/p>\n<p>bool operator&lt;(const string&amp; s1, const string&amp; s2);<br \/>\nbool operator&lt;&#061;(const string&amp; s1, const string&amp; s2);<br \/>\nbool operator&gt;(const string&amp; s1, const string&amp; s2);<br \/>\nbool operator&gt;&#061;(const string&amp; s1, const string&amp; s2);<br \/>\nbool operator&#061;&#061;(const string&amp; s1, const string&amp; s2);<br \/>\nbool operator!&#061;(const string&amp; s1, const string&amp; s2);<\/p>\n<p>ostream&amp; operator&lt;&lt;(ostream&amp; out, const string&amp; s);<br \/>\nistream&amp; operator&gt;&gt;(istream&amp; in, string&amp; s);<br \/>\n} <\/p>\n<h4 id=\"string.cpp\">string.cpp<\/h4>\n<p>#include&#034;string.h&#034;<\/p>\n<p>namespace bit<br \/>\n{<br \/>\nconst size_t string::npos &#061; -1;<\/p>\n<p>void string::reserve(size_t n)<br \/>\n{<br \/>\nif (n &gt; _capacity)<br \/>\n{<br \/>\n\/\/cout &lt;&lt; &#034;reserve:&#034; &lt;&lt; n &lt;&lt; endl;<\/p>\n<p>char* tmp &#061; new char[n &#043; 1];<br \/>\nstrcpy(tmp, _str);<br \/>\ndelete[] _str;<br \/>\n_str &#061; tmp;<br \/>\n_capacity &#061; n;<br \/>\n}<br \/>\n}<\/p>\n<p>void string::push_back(char ch)<br \/>\n{<br \/>\nif (_size &#061;&#061; _capacity)<br \/>\n{<br \/>\nreserve(_capacity &#061;&#061; 0 ? 4 : _capacity * 2);<br \/>\n}<\/p>\n<p>_str[_size] &#061; ch;<br \/>\n&#043;&#043;_size;<br \/>\n_str[_size] &#061; &#039;\\\\0&#039;;<br \/>\n}<\/p>\n<p>string&amp; string::operator&#043;&#061;(char ch)<br \/>\n{<br \/>\npush_back(ch);<br \/>\nreturn *this;<br \/>\n}<\/p>\n<p>void string::append(const char* str)<br \/>\n{<br \/>\nsize_t len &#061; strlen(str);<br \/>\nif (_size &#043; len &gt; _capacity)<br \/>\n{<br \/>\n\/\/ \u5927\u4e8e2\u500d&#xff0c;\u9700\u8981\u591a\u5c11\u5f00\u591a\u5c11&#xff0c;\u5c0f\u4e8e2\u500d\u63092\u500d\u6269<br \/>\nreserve(_size &#043; len &gt; 2 * _capacity ? _size &#043; len : 2 * _capacity);<br \/>\n}<\/p>\n<p>strcpy(_str &#043; _size, str);<br \/>\n_size &#043;&#061; len;<br \/>\n}<\/p>\n<p>string&amp; string::operator&#043;&#061;(const char* str)<br \/>\n{<br \/>\nappend(str);<br \/>\nreturn *this;<br \/>\n}<\/p>\n<p>void string::insert(size_t pos, char ch)<br \/>\n{<br \/>\nassert(pos &lt;&#061; _size);<\/p>\n<p>if (_size &#061;&#061; _capacity)<br \/>\n{<br \/>\nreserve(_capacity &#061;&#061; 0 ? 4 : _capacity * 2);<br \/>\n}<\/p>\n<p>\/\/ \u632a\u52a8\u6570\u636e<br \/>\nsize_t end &#061; _size &#043; 1;<br \/>\nwhile (end &gt; pos)<br \/>\n{<br \/>\n_str[end] &#061; _str[end &#8211; 1];<br \/>\n&#8211;end;<br \/>\n}<\/p>\n<p>_str[pos] &#061; ch;<br \/>\n&#043;&#043;_size;<br \/>\n}<\/p>\n<p>void string::insert(size_t pos, const char* s)<br \/>\n{<br \/>\nassert(pos &lt;&#061; _size);<\/p>\n<p>size_t len &#061; strlen(s);<br \/>\nif (_size &#043; len &gt; _capacity)<br \/>\n{<br \/>\n\/\/ \u5927\u4e8e2\u500d&#xff0c;\u9700\u8981\u591a\u5c11\u5f00\u591a\u5c11&#xff0c;\u5c0f\u4e8e2\u500d\u63092\u500d\u6269<br \/>\nreserve(_size &#043; len &gt; 2 * _capacity ? _size &#043; len : 2 * _capacity);<br \/>\n}<\/p>\n<p>size_t end &#061; _size &#043; len;<br \/>\nwhile (end &gt; pos &#043; len &#8211; 1)<br \/>\n{<br \/>\n_str[end] &#061; _str[end &#8211; len];<br \/>\n&#8211;end;<br \/>\n}<\/p>\n<p>for (size_t i &#061; 0; i &lt; len; i&#043;&#043;)<br \/>\n{<br \/>\n_str[pos &#043; i] &#061; s[i];<br \/>\n}<\/p>\n<p>_size &#043;&#061; len;<br \/>\n}<\/p>\n<p>void string::erase(size_t pos, size_t len)<br \/>\n{<br \/>\nassert(pos &lt; _size);<\/p>\n<p>if (len &gt;&#061; _size &#8211; pos)<br \/>\n{<br \/>\n_str[pos] &#061; &#039;\\\\0&#039;;<br \/>\n_size &#061; pos;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nfor (size_t i &#061; pos &#043; len; i &lt;&#061; _size; i&#043;&#043;)<br \/>\n{<br \/>\n_str[i &#8211; len] &#061; _str[i];<br \/>\n}<\/p>\n<p>_size -&#061; len;<br \/>\n}<br \/>\n}<\/p>\n<p>size_t string::find(char ch, size_t pos)<br \/>\n{<br \/>\nassert(pos &lt; _size);<\/p>\n<p>for (size_t i &#061; pos; i &lt; _size; i&#043;&#043;)<br \/>\n{<br \/>\nif (_str[i] &#061;&#061; ch)<br \/>\n{<br \/>\nreturn i;<br \/>\n}<br \/>\n}<\/p>\n<p>return npos;<br \/>\n}<\/p>\n<p>size_t string::find(const char* str, size_t pos)<br \/>\n{<br \/>\nassert(pos &lt; _size);<\/p>\n<p>const char* ptr &#061; strstr(_str &#043; pos, str);<br \/>\nif (ptr &#061;&#061; nullptr)<br \/>\n{<br \/>\nreturn npos;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nreturn ptr &#8211; _str;<br \/>\n}<br \/>\n}<\/p>\n<p>string string::substr(size_t pos, size_t len)<br \/>\n{<br \/>\nassert(pos &lt; _size);<\/p>\n<p>\/\/ len\u5927\u4e8e\u5269\u4f59\u5b57\u7b26\u957f\u5ea6&#xff0c;\u66f4\u65b0\u4e00\u4e0blen<br \/>\nif (len &gt; _size &#8211; pos)<br \/>\n{<br \/>\nlen &#061; _size &#8211; pos;<br \/>\n}<\/p>\n<p>string sub;<br \/>\nsub.reserve(len);<br \/>\nfor (size_t i &#061; 0; i &lt; len; i&#043;&#043;)<br \/>\n{<br \/>\nsub &#043;&#061; _str[pos &#043; i];<br \/>\n}<\/p>\n<p>return sub;<br \/>\n}<\/p>\n<p>bool operator&lt;(const string&amp; s1, const string&amp; s2)<br \/>\n{<br \/>\nreturn strcmp(s1.c_str(), s2.c_str()) &lt; 0;<br \/>\n}<\/p>\n<p>bool operator&lt;&#061;(const string&amp; s1, const string&amp; s2)<br \/>\n{<br \/>\nreturn s1 &lt; s2 || s1 &#061;&#061; s2;<br \/>\n}<\/p>\n<p>bool operator&gt;(const string&amp; s1, const string&amp; s2)<br \/>\n{<br \/>\nreturn !(s1 &lt;&#061; s2);<br \/>\n}<\/p>\n<p>bool operator&gt;&#061;(const string&amp; s1, const string&amp; s2)<br \/>\n{<br \/>\nreturn !(s1 &lt; s2);<br \/>\n}<\/p>\n<p>bool operator&#061;&#061;(const string&amp; s1, const string&amp; s2)<br \/>\n{<br \/>\nreturn strcmp(s1.c_str(), s2.c_str()) &#061;&#061; 0;<br \/>\n}<\/p>\n<p>bool operator!&#061;(const string&amp; s1, const string&amp; s2)<br \/>\n{<br \/>\nreturn !(s1 &#061;&#061; s2);<br \/>\n}<\/p>\n<p>ostream&amp; operator&lt;&lt;(ostream&amp; out, const string&amp; s)<br \/>\n{<br \/>\nfor (auto ch : s)<br \/>\n{<br \/>\nout &lt;&lt; ch;<br \/>\n}<\/p>\n<p>return out;<br \/>\n}<\/p>\n<p>istream&amp; operator&gt;&gt;(istream&amp; in, string&amp; s)<br \/>\n{<br \/>\ns.clear();<\/p>\n<p>const int N &#061; 256;<br \/>\nchar buff[N];<br \/>\nint i &#061; 0;<\/p>\n<p>char ch;<br \/>\n\/\/in &gt;&gt; ch;<br \/>\nch &#061; in.get();<br \/>\nwhile (ch !&#061; &#039; &#039; &amp;&amp; ch !&#061; &#039;\\\\n&#039;)<br \/>\n{<br \/>\nbuff[i&#043;&#043;] &#061; ch;<br \/>\nif (i &#061;&#061; N &#8211; 1)<br \/>\n{<br \/>\nbuff[i] &#061; &#039;\\\\0&#039;;<br \/>\ns &#043;&#061; buff;<\/p>\n<p>i &#061; 0;<br \/>\n}<\/p>\n<p>\/\/in &gt;&gt; ch;<br \/>\nch &#061; in.get();<br \/>\n}<\/p>\n<p>if (i &gt; 0)<br \/>\n{<br \/>\nbuff[i] &#061; &#039;\\\\0&#039;;<br \/>\ns &#043;&#061; buff;<br \/>\n}<\/p>\n<p>return in;<br \/>\n}<br \/>\n} <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63d0\u8d77 C \u4e2d\u7684 string&#xff0c;\u60f3\u5fc5\u4e0d\u5c11\u4eba\u90fd\u6709\u8fc7\u8fd9\u6837\u7684\u611f\u89e6&#xff1a;\u521d\u5b66\u65f6\u60ca\u53f9\u4e8e\u5b83\u529f\u80fd\u7684\u4e30\u5bcc\u4e0e\u4fbf\u6377&#xff0c;\u603b\u5fcd\u4e0d\u4f4f\u611f\u6168\u8fd9\u4efd \u201c\u5f00\u7bb1\u5373\u7528\u201d \u7684\u795e\u5947&#xff1b;\u6df1\u5165\u5b66\u4e60\u540e\u624d\u53d1\u73b0&#xff0c;\u8fd9\u4efd\u770b\u4f3c\u7b80\u5355\u7684 \u201c\u795e\u5947\u201d \u80cc\u540e&#xff0c;\u85cf\u7740\u52a8\u6001\u5185\u5b58\u7ba1\u7406\u3001\u62f7\u8d1d\u63a7\u5236\u3001\u8fd0\u7b97\u7b26\u91cd\u8f7d\u7b49\u5c42\u5c42\u7cbe\u5de7\u7684\u5e95\u5c42\u8bbe\u8ba1\u3002<br \/>\nstd::string\u7684\u4f7f\u7528\u00a0 \u70b9\u51fb\u53ef\u4ee5\u770b\u5230\u6807\u51c6\u5e93\u4e2dstring\u7684\u4e3b\u8981\u529f\u80fd\u3002<br \/>\n\u76ee\u5f55<br \/>\n\u7b2c\u4e00\u6b65&#xff1a;\u5f00\u4e00\u4e2astring.h\u7684\u5934\u6587\u4ef6<br \/>\n1. \u4ee3<\/p>\n","protected":false},"author":2,"featured_media":76060,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[55,190],"topic":[],"class_list":["post-76061","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-c","tag-190"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u300aSTL string \u5e95\u5c42\u590d\u523b\uff1a\u52a8\u6001\u6570\u7ec4\u3001\u62f7\u8d1d\u63a7\u5236\u4e0e\u6027\u80fd\u4f18\u5316\u300b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/76061.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u300aSTL string \u5e95\u5c42\u590d\u523b\uff1a\u52a8\u6001\u6570\u7ec4\u3001\u62f7\u8d1d\u63a7\u5236\u4e0e\u6027\u80fd\u4f18\u5316\u300b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u63d0\u8d77 C \u4e2d\u7684 string&#xff0c;\u60f3\u5fc5\u4e0d\u5c11\u4eba\u90fd\u6709\u8fc7\u8fd9\u6837\u7684\u611f\u89e6&#xff1a;\u521d\u5b66\u65f6\u60ca\u53f9\u4e8e\u5b83\u529f\u80fd\u7684\u4e30\u5bcc\u4e0e\u4fbf\u6377&#xff0c;\u603b\u5fcd\u4e0d\u4f4f\u611f\u6168\u8fd9\u4efd \u201c\u5f00\u7bb1\u5373\u7528\u201d \u7684\u795e\u5947&#xff1b;\u6df1\u5165\u5b66\u4e60\u540e\u624d\u53d1\u73b0&#xff0c;\u8fd9\u4efd\u770b\u4f3c\u7b80\u5355\u7684 \u201c\u795e\u5947\u201d \u80cc\u540e&#xff0c;\u85cf\u7740\u52a8\u6001\u5185\u5b58\u7ba1\u7406\u3001\u62f7\u8d1d\u63a7\u5236\u3001\u8fd0\u7b97\u7b26\u91cd\u8f7d\u7b49\u5c42\u5c42\u7cbe\u5de7\u7684\u5e95\u5c42\u8bbe\u8ba1\u3002 std::string\u7684\u4f7f\u7528\u00a0 \u70b9\u51fb\u53ef\u4ee5\u770b\u5230\u6807\u51c6\u5e93\u4e2dstring\u7684\u4e3b\u8981\u529f\u80fd\u3002 \u76ee\u5f55 \u7b2c\u4e00\u6b65&#xff1a;\u5f00\u4e00\u4e2astring.h\u7684\u5934\u6587\u4ef6 1. \u4ee3\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/76061.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-02-13T15:05:23+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260213150521-698f3db1a6999.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"14 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/76061.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/76061.html\",\"name\":\"\u300aSTL string \u5e95\u5c42\u590d\u523b\uff1a\u52a8\u6001\u6570\u7ec4\u3001\u62f7\u8d1d\u63a7\u5236\u4e0e\u6027\u80fd\u4f18\u5316\u300b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-02-13T15:05:23+00:00\",\"dateModified\":\"2026-02-13T15:05:23+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/76061.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/76061.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/76061.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u300aSTL string \u5e95\u5c42\u590d\u523b\uff1a\u52a8\u6001\u6570\u7ec4\u3001\u62f7\u8d1d\u63a7\u5236\u4e0e\u6027\u80fd\u4f18\u5316\u300b\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u300aSTL string \u5e95\u5c42\u590d\u523b\uff1a\u52a8\u6001\u6570\u7ec4\u3001\u62f7\u8d1d\u63a7\u5236\u4e0e\u6027\u80fd\u4f18\u5316\u300b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/76061.html","og_locale":"zh_CN","og_type":"article","og_title":"\u300aSTL string \u5e95\u5c42\u590d\u523b\uff1a\u52a8\u6001\u6570\u7ec4\u3001\u62f7\u8d1d\u63a7\u5236\u4e0e\u6027\u80fd\u4f18\u5316\u300b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u63d0\u8d77 C \u4e2d\u7684 string&#xff0c;\u60f3\u5fc5\u4e0d\u5c11\u4eba\u90fd\u6709\u8fc7\u8fd9\u6837\u7684\u611f\u89e6&#xff1a;\u521d\u5b66\u65f6\u60ca\u53f9\u4e8e\u5b83\u529f\u80fd\u7684\u4e30\u5bcc\u4e0e\u4fbf\u6377&#xff0c;\u603b\u5fcd\u4e0d\u4f4f\u611f\u6168\u8fd9\u4efd \u201c\u5f00\u7bb1\u5373\u7528\u201d \u7684\u795e\u5947&#xff1b;\u6df1\u5165\u5b66\u4e60\u540e\u624d\u53d1\u73b0&#xff0c;\u8fd9\u4efd\u770b\u4f3c\u7b80\u5355\u7684 \u201c\u795e\u5947\u201d \u80cc\u540e&#xff0c;\u85cf\u7740\u52a8\u6001\u5185\u5b58\u7ba1\u7406\u3001\u62f7\u8d1d\u63a7\u5236\u3001\u8fd0\u7b97\u7b26\u91cd\u8f7d\u7b49\u5c42\u5c42\u7cbe\u5de7\u7684\u5e95\u5c42\u8bbe\u8ba1\u3002 std::string\u7684\u4f7f\u7528\u00a0 \u70b9\u51fb\u53ef\u4ee5\u770b\u5230\u6807\u51c6\u5e93\u4e2dstring\u7684\u4e3b\u8981\u529f\u80fd\u3002 \u76ee\u5f55 \u7b2c\u4e00\u6b65&#xff1a;\u5f00\u4e00\u4e2astring.h\u7684\u5934\u6587\u4ef6 1. \u4ee3","og_url":"https:\/\/www.wsisp.com\/helps\/76061.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-02-13T15:05:23+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260213150521-698f3db1a6999.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"14 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/76061.html","url":"https:\/\/www.wsisp.com\/helps\/76061.html","name":"\u300aSTL string \u5e95\u5c42\u590d\u523b\uff1a\u52a8\u6001\u6570\u7ec4\u3001\u62f7\u8d1d\u63a7\u5236\u4e0e\u6027\u80fd\u4f18\u5316\u300b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-02-13T15:05:23+00:00","dateModified":"2026-02-13T15:05:23+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/76061.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/76061.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/76061.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u300aSTL string \u5e95\u5c42\u590d\u523b\uff1a\u52a8\u6001\u6570\u7ec4\u3001\u62f7\u8d1d\u63a7\u5236\u4e0e\u6027\u80fd\u4f18\u5316\u300b"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/76061","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=76061"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/76061\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/76060"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=76061"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=76061"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=76061"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=76061"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}