{"id":91734,"date":"2026-08-08T11:17:04","date_gmt":"2026-08-08T03:17:04","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/91734.html"},"modified":"2026-08-08T11:17:04","modified_gmt":"2026-08-08T03:17:04","slug":"c%e5%86%85%e5%ad%98%e7%ae%a1%e7%90%86%ef%bc%9a%e7%bc%96%e8%af%91%e5%99%a8%e7%9a%84%e4%bc%98%e5%8c%96%e3%80%81c%e5%86%85%e5%ad%98%e5%88%92%e5%88%86%e3%80%81new%e3%80%81delete%e5%85%b3%e9%94%ae","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/91734.html","title":{"rendered":"C++\u5185\u5b58\u7ba1\u7406\uff1a\u7f16\u8bd1\u5668\u7684\u4f18\u5316\u3001C++\u5185\u5b58\u5212\u5206\u3001new\u3001delete\u5173\u952e\u5b57\u53ca\u5176\u5e95\u5c42"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260808031701-6a769fadd213a.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p> \u535a\u4e3b\u540d\u79f0&#xff1a;deM0one<\/p>\n<p> \u2b50\ufe0fC&#043;&#043;\u4e13\u680f&#xff1a;<br \/>\n  C&#043;&#043;<\/p>\n<h3>\n<h3>\u6587\u7ae0\u76ee\u5f55<\/h3>\n<ul>\n<li>\n<ul>\n<li>&#064;[toc]<\/li>\n<\/ul>\n<\/li>\n<li>C&#043;&#043; \u5185\u5b58\u7ba1\u7406\u8be6\u89e3&#xff08;new\/delete \u4e0e\u5185\u5b58\u5206\u533a&#xff09;<\/li>\n<li>\n<ul>\n<li>\u4e00\u3001\u5f15\u8a00<\/li>\n<li>\u4e8c\u3001\u7c7b\u4e0e\u5bf9\u8c61\u6536\u5c3e&#xff1a;\u5bf9\u8c61\u62f7\u8d1d\u65f6\u7684\u7f16\u8bd1\u5668\u4f18\u5316<\/li>\n<li>\n<ul>\n<li>2.1 \u7f16\u8bd1\u5668\u4e3a\u4ec0\u4e48\u4f1a\u4f18\u5316\u62f7\u8d1d<\/li>\n<li>2.2 \u5e38\u89c1\u7684\u4f18\u5316\u573a\u666f<\/li>\n<li>2.3 \u6f14\u793a\u4e0e\u7ed3\u8bba<\/li>\n<\/ul>\n<\/li>\n<li>\u4e09\u3001C&#043;&#043; \u7a0b\u5e8f\u7684\u5185\u5b58\u5206\u533a<\/li>\n<li>\n<ul>\n<li>3.1 \u56db\u5927\u533a\u57df<\/li>\n<li>3.2 \u6307\u9488\u4e0e\u6307\u5411\u7684\u5185\u5bb9\u53ef\u80fd\u5728\u4e0d\u540c\u533a\u57df<\/li>\n<li>3.3 \u7ecf\u5178\u7ec3\u4e60&#xff1a;\u8fd9\u4e9b\u53d8\u91cf\u90fd\u5728\u54ea\u4e2a\u533a&#xff1f;<\/li>\n<li>3.4 \u6838\u5fc3\u7406\u89e3&#xff1a;\u5206\u533a\u5b9e\u9645\u4e0a\u5206\u7684\u662f&#034;\u751f\u547d\u5468\u671f&#034;<\/li>\n<\/ul>\n<\/li>\n<li>\u56db\u3001\u56de\u987e C \u8bed\u8a00\u7684\u52a8\u6001\u5185\u5b58\u7ba1\u7406<\/li>\n<li>\u4e94\u3001C&#043;&#043; \u7684 new \/ delete \u5173\u952e\u5b57<\/li>\n<li>\n<ul>\n<li>5.1 \u57fa\u672c\u7528\u6cd5<\/li>\n<li>5.2 \u7533\u8bf7\u7a7a\u95f4\u7684\u540c\u65f6\u521d\u59cb\u5316<\/li>\n<li>5.3 \u81ea\u5b9a\u4e49\u7c7b\u578b\u7684\u884c\u4e3a<\/li>\n<li>5.4 new \u5931\u8d25\u7684\u5904\u7406\u65b9\u5f0f<\/li>\n<\/ul>\n<\/li>\n<li>\u516d\u3001\u5185\u5b58\u4e0e\u865a\u62df\u5185\u5b58<\/li>\n<li>\u4e03\u3001operator new \u4e0e operator delete&#xff08;\u91cd\u70b9&#xff09;<\/li>\n<li>\n<ul>\n<li>7.1 \u5b9a\u4f4d<\/li>\n<li>7.2 \u8c03\u7528\u5173\u7cfb<\/li>\n<\/ul>\n<\/li>\n<li>\u516b\u3001new \/ delete \u7684\u5b9e\u73b0\u539f\u7406&#xff08;\u91cd\u70b9&#xff09;<\/li>\n<li>\n<ul>\n<li>8.1 \u5185\u7f6e\u7c7b\u578b<\/li>\n<li>8.2 \u81ea\u5b9a\u4e49\u7c7b\u578b<\/li>\n<\/ul>\n<\/li>\n<li>\u4e5d\u3001new \/ delete \u4e0e new[] \/ delete[] \u7684\u5339\u914d&#xff08;\u6613\u9519\u70b9&#xff09;<\/li>\n<li>\n<ul>\n<li>9.1 \u5339\u914d\u89c4\u5219<\/li>\n<li>9.2 \u53cd\u4f8b\u6f14\u793a<\/li>\n<li>9.3 \u7ed3\u8bba<\/li>\n<\/ul>\n<\/li>\n<li>\u5341\u3001\u603b\u7ed3<\/li>\n<li>\n<ul>\n<li>10.1 \u5168\u6587\u56de\u987e<\/li>\n<li>10.2 \u5e38\u89c1\u9762\u8bd5\u9898\u81ea\u6d4b\u6e05\u5355<\/li>\n<\/ul>\n<\/li>\n<li>\u4efb\u4f55\u7684\u5efa\u8bae\u4e0e\u6279\u8bc4\u6b22\u8fce\u6307\u51fa&#xff0c;\u6211\u4eec\u5171\u540c\u8fdb\u6b65&#xff01;<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/h3>\n<hr \/>\n<h2>C&#043;&#043; \u5185\u5b58\u7ba1\u7406\u8be6\u89e3&#xff08;new\/delete \u4e0e\u5185\u5b58\u5206\u533a&#xff09;<\/h2>\n<p>\u4eca\u65e5\u5b66\u4e60&#xff1a; \u7c7b\u4e0e\u5bf9\u8c61\u6536\u5c3e&#xff0c;\u7f16\u8bd1\u5668\u7684\u81ea\u52a8\u4f18\u5316\u4f55\u65f6\u4f18\u5316&#xff0c;\u5728\u54ea\u91cc\u4f18\u5316<\/p>\n<h3>\u4e00\u3001\u5f15\u8a00<\/h3>\n<ul>\n<li>\u5185\u5b58\u662f\u7a0b\u5e8f\u8fd0\u884c\u7684\u6838\u5fc3\u8d44\u6e90\u4e4b\u4e00&#xff08;CPU\u3001GPU\u4e00\u79cd\u7279\u6b8a\u7684CPU\u3001\u5185\u5b58&#xff09;<\/li>\n<li>\u4e3a\u4ec0\u4e48\u8981\u7406\u89e3\u5185\u5b58\u7ba1\u7406&#xff1a;\u5199\u51fa\u9ad8\u6548\u3001\u4e0d\u51fa\u9519\u7684 C&#043;&#043; \u7a0b\u5e8f<\/li>\n<li>\u672c\u7bc7\u535a\u5ba2\u7684\u9605\u8bfb\u8def\u7ebf\u56fe&#xff08;\u5148\u5206\u533a\u3001\u518d\u7528\u6cd5\u3001\u540e\u539f\u7406&#xff09;<\/li>\n<\/ul>\n<h3>\u4e8c\u3001\u7c7b\u4e0e\u5bf9\u8c61\u6536\u5c3e&#xff1a;\u5bf9\u8c61\u62f7\u8d1d\u65f6\u7684\u7f16\u8bd1\u5668\u4f18\u5316<\/h3>\n<h4>2.1 \u7f16\u8bd1\u5668\u4e3a\u4ec0\u4e48\u4f1a\u4f18\u5316\u62f7\u8d1d<\/h4>\n<ul>\n<li>\u73b0\u4ee3\u7f16\u8bd1\u5668\u4f1a\u5728\u4e0d\u5f71\u54cd\u6b63\u786e\u6027\u7684\u524d\u63d0\u4e0b&#xff0c;\u5c3d\u53ef\u80fd\u51cf\u5c11\u4f20\u53c2\u548c\u8fd4\u56de\u8fc7\u7a0b\u4e2d\u53ef\u7701\u7565\u7684\u62f7\u8d1d<\/li>\n<li>C&#043;&#043; \u6807\u51c6\u6ca1\u6709\u4e25\u683c\u89c4\u5b9a\u4f18\u5316\u65b9\u5f0f&#xff0c;\u7531\u5404\u7f16\u8bd1\u5668\u81ea\u884c\u5904\u7406<\/li>\n<\/ul>\n<h4>2.2 \u5e38\u89c1\u7684\u4f18\u5316\u573a\u666f<\/h4>\n<ul>\n<li>\u540c\u4e00\u8868\u8fbe\u5f0f\u5185\u8fde\u7eed\u62f7\u8d1d\u7684&#034;\u5408\u5e76\u4f18\u5316&#034;<\/li>\n<li>\u66f4\u6fc0\u8fdb\u7f16\u8bd1\u5668\u7684\u8de8\u884c\u3001\u8de8\u8868\u8fbe\u5f0f\u5408\u5e76\u4f18\u5316 <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260808031702-6a769fae691cd.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/> \u7f16\u8bd1\u5668\u80fd\u591f\u5c06\u4e00\u6b21\u6784\u9020&#xff0c;\u4e00\u6b21\u62f7\u8d1d\u6784\u9020\u76f4\u63a5\u4f18\u5316\u6210\u4e00\u6b21\u6784\u9020&#xff0c;\u51cf\u5c11\u591a\u4f59\u7684\u6784\u9020&#xff0c;\u63d0\u9ad8\u6548\u7387\u3002 <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260808031702-6a769fae78e30.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/> \u6b64\u5904\u7f16\u8bd1\u5668\u5c06\u4e00\u6b21\u6784\u9020&#xff0c;\u4e00\u6b21\u4f20\u503c\u8fd4\u56de\u7684\u62f7\u8d1d\u6784\u9020\u7684\u4e34\u65f6\u5bf9\u8c61&#xff0c;\u4f18\u5316\u6210\u76f4\u63a5\u75281\u6765\u6784\u9020\u4e34\u65f6\u5bf9\u8c61\u8fd4\u56de&#xff0c;\u5c06aa\u7684\u6784\u9020\u7ed9\u4f18\u5316\u6389\u4e86\u3002 <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260808031702-6a769fae9bc2a.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/> \u6b64\u5904\u7f16\u8bd1\u5668\u5374\u6ca1\u6709\u4f18\u5316\u8fd9\u662f\u4e3a\u4ec0\u4e48&#xff1f;\u56e0\u4e3aret&#061;f2()\u5c5e\u4e8e\u8d4b\u503c\u62f7\u8d1d&#xff0c;\u6ca1\u6709\u4f20\u503c\u4f20\u53c2\u7684\u8fc7\u7a0b&#xff0c;\u4e5f\u4e0d\u662f\u5bf9\u8c61\u7684\u6784\u9020&#xff0c;\u6240\u4ee5\u7f16\u8bd1\u5668\u6ca1\u6709\u505a\u6fc0\u8fdb\u7684\u4f18\u5316\u3002<\/li>\n<\/ul>\n<h4>2.3 \u6f14\u793a\u4e0e\u7ed3\u8bba<\/h4>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260808031702-6a769faed79e7.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<ul>\n<li>\u793a\u4f8b&#xff1a;f2().Print() \u76f4\u63a5\u5bf9\u4e34\u65f6\u5bf9\u8c61\u8c03\u7528\u6210\u5458\u51fd\u6570&#xff0c;\u89c2\u5bdf\u62f7\u8d1d\u6784\u9020\u7684\u8c03\u7528\u6b21\u6570&#xff08;\u4f18\u5316\u540e\u4e3a 0 \u6b21&#xff09;<\/li>\n<li>\u7ed3\u8bba&#xff1a;\u7406\u89e3\u62f7\u8d1d\u6784\u9020\u4e0e\u8d4b\u503c\u91cd\u8f7d\u7684\u771f\u5b9e\u8c03\u7528\u65f6\u673a<\/li>\n<\/ul>\n<h3>\u4e09\u3001C&#043;&#043; \u7a0b\u5e8f\u7684\u5185\u5b58\u5206\u533a<\/h3>\n<h4>3.1 \u56db\u5927\u533a\u57df<\/h4>\n<ul>\n<li>\u6808\u533a&#xff1a;\u5c40\u90e8\u53d8\u91cf\u3001\u51fd\u6570\u53c2\u6570&#xff0c;\u7f16\u8bd1\u5668\u81ea\u52a8\u5206\u914d\u91ca\u653e<\/li>\n<li>\u5806\u533a&#xff1a;\u52a8\u6001\u7533\u8bf7\u7684\u5185\u5b58&#xff0c;\u9700\u624b\u52a8\u7ba1\u7406<\/li>\n<li>\u6570\u636e\u6bb5&#xff08;\u9759\u6001\u533a&#xff09;&#xff1a;\u5168\u5c40\u53d8\u91cf\u3001\u9759\u6001\u53d8\u91cf<\/li>\n<li>\u4ee3\u7801\u6bb5&#xff08;\u5e38\u91cf\u533a&#xff09;&#xff1a;\u5e38\u91cf\u5b57\u7b26\u4e32\u3001\u7a0b\u5e8f\u6307\u4ee4<\/li>\n<\/ul>\n<h4>3.2 \u6307\u9488\u4e0e\u6307\u5411\u7684\u5185\u5bb9\u53ef\u80fd\u5728\u4e0d\u540c\u533a\u57df<\/h4>\n<ul>\n<li>\u6307\u9488\u53d8\u91cf\u672c\u8eab\u5728\u6808\u4e0a&#xff0c;\u6307\u5411\u7684\u5185\u5bb9\u53ef\u80fd\u5728\u6808\u3001\u5806\u3001\u5e38\u91cf\u533a\u7b49<\/li>\n<\/ul>\n<h4>3.3 \u7ecf\u5178\u7ec3\u4e60&#xff1a;\u8fd9\u4e9b\u53d8\u91cf\u90fd\u5728\u54ea\u4e2a\u533a&#xff1f;<\/h4>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260808031703-6a769faf08ecf.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h4>3.4 \u6838\u5fc3\u7406\u89e3&#xff1a;\u5206\u533a\u5b9e\u9645\u4e0a\u5206\u7684\u662f&#034;\u751f\u547d\u5468\u671f&#034;<\/h4>\n<h3>\u56db\u3001\u56de\u987e C \u8bed\u8a00\u7684\u52a8\u6001\u5185\u5b58\u7ba1\u7406<\/h3>\n<ul>\n<li>4.1 malloc \/ calloc \/ realloc \/ free \u7684\u57fa\u672c\u7528\u6cd5<\/li>\n<li>4.2 \u4e09\u8005\u7684\u533a\u522b&#xff08;\u521d\u59cb\u5316\u4e0e\u5426\u3001\u6269\u5bb9\u65b9\u5f0f&#xff09;<\/li>\n<li>4.3 \u4e3a\u540e\u6587\u4e0e new\/delete \u5bf9\u6bd4\u505a\u94fa\u57ab<\/li>\n<\/ul>\n<h3>\u4e94\u3001C&#043;&#043; \u7684 new \/ delete \u5173\u952e\u5b57<\/h3>\n<h4>5.1 \u57fa\u672c\u7528\u6cd5<\/h4>\n<ul>\n<li>new int \/ new int[10]&#xff0c;delete p \/ delete[] p<\/li>\n<\/ul>\n<h4>5.2 \u7533\u8bf7\u7a7a\u95f4\u7684\u540c\u65f6\u521d\u59cb\u5316<\/h4>\n<ul>\n<li>new int(5)<\/li>\n<li>new int[10]{1, 2, 3, 4, 5}<\/li>\n<\/ul>\n<h4>5.3 \u81ea\u5b9a\u4e49\u7c7b\u578b\u7684\u884c\u4e3a<\/h4>\n<ul>\n<li>new \u4f1a\u8c03\u7528\u6784\u9020\u51fd\u6570&#xff1b;\u6ca1\u6709\u9ed8\u8ba4\u6784\u9020\u51fd\u6570\u65f6\u9700\u8981\u663e\u5f0f\u4f20\u503c<\/li>\n<li>delete \u4f1a\u8c03\u7528\u6790\u6784\u51fd\u6570<\/li>\n<\/ul>\n<h4>5.4 new \u5931\u8d25\u7684\u5904\u7406\u65b9\u5f0f<\/h4>\n<ul>\n<li>new \u5931\u8d25\u4f1a\u629b\u5f02\u5e38&#xff08;\u533a\u522b\u4e8e malloc \u8fd4\u56de NULL&#xff09;<\/li>\n<li>try\/catch \u6355\u83b7\u793a\u4f8b&#xff1a;\u7533\u8bf7\u8d85\u5927\u7a7a\u95f4&#xff0c;\u8f93\u51fa\u5f02\u5e38\u4fe1\u606f<\/li>\n<\/ul>\n<h3>\u516d\u3001\u5185\u5b58\u4e0e\u865a\u62df\u5185\u5b58<\/h3>\n<ul>\n<li>6.1 32 \u4f4d\u7cfb\u7edf&#xff1a;\u7ea6 4G \u865a\u62df\u5730\u5740\u7a7a\u95f4<\/li>\n<li>6.2 64 \u4f4d\u7cfb\u7edf&#xff1a;2^64 \u4e2a\u5b57\u8282&#xff08;\u7ea6 160 \u591a\u4ebf G&#xff09;<\/li>\n<li>6.3 \u865a\u62df\u5185\u5b58\u7684\u76f4\u89c2\u7406\u89e3&#xff08;\u5730\u5740\u7a7a\u95f4\u5927\u5c0f\u7531\u7cfb\u7edf\u4f4d\u6570\u51b3\u5b9a&#xff09;<\/li>\n<\/ul>\n<h3>\u4e03\u3001operator new \u4e0e operator delete&#xff08;\u91cd\u70b9&#xff09;<\/h3>\n<h4>7.1 \u5b9a\u4f4d<\/h4>\n<ul>\n<li>new\/delete \u662f\u7528\u6237\u4f7f\u7528\u7684\u64cd\u4f5c\u7b26<\/li>\n<li>operator new\/operator delete \u662f\u7cfb\u7edf\u63d0\u4f9b\u7684\u5168\u5c40\u51fd\u6570<\/li>\n<\/ul>\n<h4>7.2 \u8c03\u7528\u5173\u7cfb<\/h4>\n<ul>\n<li>new \u5e95\u5c42\u8c03\u7528 operator new \u7533\u8bf7\u7a7a\u95f4<\/li>\n<li>delete \u5e95\u5c42\u8c03\u7528 operator delete \u91ca\u653e\u7a7a\u95f4<\/li>\n<\/ul>\n<h3>\u516b\u3001new \/ delete \u7684\u5b9e\u73b0\u539f\u7406&#xff08;\u91cd\u70b9&#xff09;<\/h3>\n<h4>8.1 \u5185\u7f6e\u7c7b\u578b<\/h4>\n<ul>\n<li>\u4e0e malloc\/free \u57fa\u672c\u7c7b\u4f3c<\/li>\n<li>\u533a\u522b\u4e00&#xff1a;new\/delete \u7ba1\u7406\u5355\u4e2a\u5143\u7d20&#xff0c;new[]\/delete[] \u7ba1\u7406\u8fde\u7eed\u7a7a\u95f4<\/li>\n<li>\u533a\u522b\u4e8c&#xff1a;new \u5931\u8d25\u629b\u5f02\u5e38&#xff0c;malloc \u5931\u8d25\u8fd4\u56de NULL<\/li>\n<\/ul>\n<h4>8.2 \u81ea\u5b9a\u4e49\u7c7b\u578b<\/h4>\n<ul>\n<li>new \u7684\u539f\u7406&#xff1a;\n<li>\u8c03\u7528 operator new \u7533\u8bf7\u7a7a\u95f4<\/li>\n<li>\u5728\u7533\u8bf7\u7684\u7a7a\u95f4\u4e0a\u6267\u884c\u6784\u9020\u51fd\u6570<\/li>\n<\/li>\n<li>delete \u7684\u539f\u7406&#xff1a;\n<li>\u5728\u7a7a\u95f4\u4e0a\u6267\u884c\u6790\u6784\u51fd\u6570<\/li>\n<li>\u8c03\u7528 operator delete \u91ca\u653e\u7a7a\u95f4<\/li>\n<\/li>\n<li>\u5173\u952e\u70b9&#xff1a;new \u7684\u5185\u6838\u662f malloc&#xff0c;delete \u7684\u5185\u6838\u662f free<\/li>\n<li>\u8865\u5145&#xff1a;\u5bf9\u4e8e\u5185\u7f6e\u7c7b\u578b&#xff0c;\u7528 free \u8fd8\u662f delete \u6ca1\u6709\u533a\u522b<\/li>\n<\/ul>\n<h3>\u4e5d\u3001new \/ delete \u4e0e new[] \/ delete[] \u7684\u5339\u914d&#xff08;\u6613\u9519\u70b9&#xff09;<\/h3>\n<h4>9.1 \u5339\u914d\u89c4\u5219<\/h4>\n<ul>\n<li>delete \u662f\u9488\u5bf9 new \u7684&#xff0c;delete[] \u662f\u9488\u5bf9 new[] \u7684<\/li>\n<\/ul>\n<h4>9.2 \u53cd\u4f8b\u6f14\u793a<\/h4>\n<ul>\n<li>new A[10] \u5374\u7528 delete p \u4f1a\u600e\u6837<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260808031703-6a769faf270f0.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/> \u7f16\u8bd1\u5668\u5bf9\u4e8e\u591a\u4e2a\u5bf9\u8c61\u7684\u6570\u7ec4\u7684\u65f6\u5019\u4f1a\u5728\u5934\u4e0a\u591a\u5f00\u56db\u4e2a\u5b57\u8282&#xff0c;\u7528\u4e8e\u5b58\u50a8\u6570\u7ec4\u5143\u7d20\u4e2a\u6570&#xff0c;\u56e0\u4e3aB\u7c7b\u578b\u6ca1\u6709\u5199\u6790\u6784\u51fd\u6570\u6240\u4ee5\u7f16\u8bd1\u5668\u5c06\u591a\u4f59\u7684\u56db\u5b57\u8282\u7ed9\u4f18\u5316\u6389\u4e86&#xff0c;\u4f46\u662fA\u5199\u4e86\u6790\u6784\u51fd\u6570&#xff0c;\u5374\u9519\u8bef\u5730\u914d\u7f6e\u4e86delete&#xff0c;\u6ca1\u6709\u6b63\u786e\u8c03\u7528\u6790\u6784\u51fd\u6570&#xff0c;\u91ca\u653e\u4f4d\u7f6e\u9519\u8bef\u5bfc\u81f4\u62a5\u9519<\/p>\n<h4>9.3 \u7ed3\u8bba<\/h4>\n<ul>\n<li>\u4e8c\u8005\u4e00\u5b9a\u8981\u5339\u914d\u4f7f\u7528&#xff0c;\u4e0d\u8981\u9519\u914d<\/li>\n<\/ul>\n<h3>\u5341\u3001\u603b\u7ed3<\/h3>\n<h4>10.1 \u5168\u6587\u56de\u987e<\/h4>\n<p>C&#043;&#043;\u7a0b\u5e8f\u7684\u5185\u5b58\u5212\u5206\u4e0eC\u8bed\u8a00\u57fa\u672c\u4e00\u8109\u76f8\u627f&#xff0c;\u8fd9\u4e5f\u4f53\u73b0\u4e86C&#043;&#043;\u5bf9C\u8bed\u8a00\u7684\u517c\u5bb9&#xff0c;C&#043;&#043;\u4e2d\u65b0\u589e\u7684new\u548cdelete\u5173\u952e\u5b57\u76f8\u6bd4C\u8bed\u8a00\u7684malloc&#xff0c;\u53ef\u4ee5\u66f4\u4fbf\u6377\u5730\u5b9e\u73b0\u5185\u5b58\u7684\u7533\u8bf7\u548c\u521d\u59cb\u5316&#xff0c;\u662f\u5bf9\u4ee3\u7801\u7b80\u6d01\u6027\u7684\u63d0\u5347&#xff0c;\u53e6\u5916\u5bf9\u4e8emalloc\u548cfree&#xff0c;new\u548cdelete&#xff0c;\u4ee5\u53canew[]\u548cdelete[]\u6700\u597d\u642d\u914d\u4f7f\u7528&#xff0c;\u4e0d\u53ef\u9519\u914d&#xff0c;\u51cf\u5c11\u62a5\u9519\u548c\u5d29\u6e83\u7684\u98ce\u9669\u3002<\/p>\n<h4>10.2 \u5e38\u89c1\u9762\u8bd5\u9898\u81ea\u6d4b\u6e05\u5355<\/h4>\n<ul>\n<li>\u5404\u53d8\u91cf\u5206\u522b\u5b58\u5728\u54ea\u4e2a\u533a&#xff1f;<\/li>\n<li>new \u548c malloc \u7684\u533a\u522b&#xff1f;<\/li>\n<li>new \u4e00\u4e2a\u5bf9\u8c61\u7ecf\u5386\u4e86\u54ea\u4e9b\u6b65\u9aa4&#xff1f;<\/li>\n<li>delete[] \u548c delete \u6df7\u7528\u4f1a\u6709\u4ec0\u4e48\u95ee\u9898&#xff1f;<\/li>\n<\/ul>\n<h3>\u4efb\u4f55\u7684\u5efa\u8bae\u4e0e\u6279\u8bc4\u6b22\u8fce\u6307\u51fa&#xff0c;\u6211\u4eec\u5171\u540c\u8fdb\u6b65&#xff01;<\/h3>\n","protected":false},"excerpt":{"rendered":"<p>\u535a\u4e3b\u540d\u79f0&#xff1a;deM0one\u2b50\ufe0fC\u4e13\u680f&#xff1a;C\u6587\u7ae0\u76ee\u5f55[toc]C \u5185\u5b58\u7ba1\u7406\u8be6\u89e3&#xff08;new\/delete \u4e0e\u5185\u5b58\u5206\u533a&#xff09;\u4e00\u3001\u5f15\u8a00\u4e8c\u3001\u7c7b\u4e0e\u5bf9\u8c61\u6536\u5c3e&#xff1a;\u5bf9\u8c61\u62f7\u8d1d\u65f6\u7684\u7f16\u8bd1\u5668\u4f18\u53162.1 \u7f16\u8bd1\u5668\u4e3a\u4ec0\u4e48\u4f1a\u4f18\u5316\u62f7\u8d1d2.2 \u5e38\u89c1\u7684\u4f18\u5316\u573a\u666f2.3 \u6f14\u793a\u4e0e\u7ed3\u8bba\u4e09\u3001C \u7a0b\u5e8f\u7684\u5185\u5b58\u5206\u533a3.1 \u56db\u5927\u533a\u57df3.2 \u6307\u9488\u4e0e\u6307\u5411\u7684\u5185\u5bb9\u53ef\u80fd\u5728\u4e0d\u540c\u533a\u57df3.3 \u7ecf\u5178\u7ec3\u4e60&#xff1a;\u8fd9\u4e9b\u53d8\u91cf\u90fd\u5728\u54ea\u4e2a\u533a&#xff1f;3.4 \u6838\u5fc3\u7406\u89e3&#xff1a;\u5206\u533a\u5b9e\u9645\u4e0a<\/p>\n","protected":false},"author":2,"featured_media":91727,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[55,99,426],"topic":[],"class_list":["post-91734","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-c","tag-java","tag-jvm"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>C++\u5185\u5b58\u7ba1\u7406\uff1a\u7f16\u8bd1\u5668\u7684\u4f18\u5316\u3001C++\u5185\u5b58\u5212\u5206\u3001new\u3001delete\u5173\u952e\u5b57\u53ca\u5176\u5e95\u5c42 - \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\/91734.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C++\u5185\u5b58\u7ba1\u7406\uff1a\u7f16\u8bd1\u5668\u7684\u4f18\u5316\u3001C++\u5185\u5b58\u5212\u5206\u3001new\u3001delete\u5173\u952e\u5b57\u53ca\u5176\u5e95\u5c42 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u535a\u4e3b\u540d\u79f0&#xff1a;deM0one\u2b50\ufe0fC\u4e13\u680f&#xff1a;C\u6587\u7ae0\u76ee\u5f55[toc]C \u5185\u5b58\u7ba1\u7406\u8be6\u89e3&#xff08;new\/delete \u4e0e\u5185\u5b58\u5206\u533a&#xff09;\u4e00\u3001\u5f15\u8a00\u4e8c\u3001\u7c7b\u4e0e\u5bf9\u8c61\u6536\u5c3e&#xff1a;\u5bf9\u8c61\u62f7\u8d1d\u65f6\u7684\u7f16\u8bd1\u5668\u4f18\u53162.1 \u7f16\u8bd1\u5668\u4e3a\u4ec0\u4e48\u4f1a\u4f18\u5316\u62f7\u8d1d2.2 \u5e38\u89c1\u7684\u4f18\u5316\u573a\u666f2.3 \u6f14\u793a\u4e0e\u7ed3\u8bba\u4e09\u3001C \u7a0b\u5e8f\u7684\u5185\u5b58\u5206\u533a3.1 \u56db\u5927\u533a\u57df3.2 \u6307\u9488\u4e0e\u6307\u5411\u7684\u5185\u5bb9\u53ef\u80fd\u5728\u4e0d\u540c\u533a\u57df3.3 \u7ecf\u5178\u7ec3\u4e60&#xff1a;\u8fd9\u4e9b\u53d8\u91cf\u90fd\u5728\u54ea\u4e2a\u533a&#xff1f;3.4 \u6838\u5fc3\u7406\u89e3&#xff1a;\u5206\u533a\u5b9e\u9645\u4e0a\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/91734.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-08T03:17:04+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260808031701-6a769fadd213a.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=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/91734.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/91734.html\",\"name\":\"C++\u5185\u5b58\u7ba1\u7406\uff1a\u7f16\u8bd1\u5668\u7684\u4f18\u5316\u3001C++\u5185\u5b58\u5212\u5206\u3001new\u3001delete\u5173\u952e\u5b57\u53ca\u5176\u5e95\u5c42 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-08T03:17:04+00:00\",\"dateModified\":\"2026-08-08T03:17:04+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/91734.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/91734.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/91734.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"C++\u5185\u5b58\u7ba1\u7406\uff1a\u7f16\u8bd1\u5668\u7684\u4f18\u5316\u3001C++\u5185\u5b58\u5212\u5206\u3001new\u3001delete\u5173\u952e\u5b57\u53ca\u5176\u5e95\u5c42\"}]},{\"@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":"C++\u5185\u5b58\u7ba1\u7406\uff1a\u7f16\u8bd1\u5668\u7684\u4f18\u5316\u3001C++\u5185\u5b58\u5212\u5206\u3001new\u3001delete\u5173\u952e\u5b57\u53ca\u5176\u5e95\u5c42 - \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\/91734.html","og_locale":"zh_CN","og_type":"article","og_title":"C++\u5185\u5b58\u7ba1\u7406\uff1a\u7f16\u8bd1\u5668\u7684\u4f18\u5316\u3001C++\u5185\u5b58\u5212\u5206\u3001new\u3001delete\u5173\u952e\u5b57\u53ca\u5176\u5e95\u5c42 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u535a\u4e3b\u540d\u79f0&#xff1a;deM0one\u2b50\ufe0fC\u4e13\u680f&#xff1a;C\u6587\u7ae0\u76ee\u5f55[toc]C \u5185\u5b58\u7ba1\u7406\u8be6\u89e3&#xff08;new\/delete \u4e0e\u5185\u5b58\u5206\u533a&#xff09;\u4e00\u3001\u5f15\u8a00\u4e8c\u3001\u7c7b\u4e0e\u5bf9\u8c61\u6536\u5c3e&#xff1a;\u5bf9\u8c61\u62f7\u8d1d\u65f6\u7684\u7f16\u8bd1\u5668\u4f18\u53162.1 \u7f16\u8bd1\u5668\u4e3a\u4ec0\u4e48\u4f1a\u4f18\u5316\u62f7\u8d1d2.2 \u5e38\u89c1\u7684\u4f18\u5316\u573a\u666f2.3 \u6f14\u793a\u4e0e\u7ed3\u8bba\u4e09\u3001C \u7a0b\u5e8f\u7684\u5185\u5b58\u5206\u533a3.1 \u56db\u5927\u533a\u57df3.2 \u6307\u9488\u4e0e\u6307\u5411\u7684\u5185\u5bb9\u53ef\u80fd\u5728\u4e0d\u540c\u533a\u57df3.3 \u7ecf\u5178\u7ec3\u4e60&#xff1a;\u8fd9\u4e9b\u53d8\u91cf\u90fd\u5728\u54ea\u4e2a\u533a&#xff1f;3.4 \u6838\u5fc3\u7406\u89e3&#xff1a;\u5206\u533a\u5b9e\u9645\u4e0a","og_url":"https:\/\/www.wsisp.com\/helps\/91734.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-08T03:17:04+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260808031701-6a769fadd213a.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/91734.html","url":"https:\/\/www.wsisp.com\/helps\/91734.html","name":"C++\u5185\u5b58\u7ba1\u7406\uff1a\u7f16\u8bd1\u5668\u7684\u4f18\u5316\u3001C++\u5185\u5b58\u5212\u5206\u3001new\u3001delete\u5173\u952e\u5b57\u53ca\u5176\u5e95\u5c42 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-08T03:17:04+00:00","dateModified":"2026-08-08T03:17:04+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/91734.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/91734.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/91734.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"C++\u5185\u5b58\u7ba1\u7406\uff1a\u7f16\u8bd1\u5668\u7684\u4f18\u5316\u3001C++\u5185\u5b58\u5212\u5206\u3001new\u3001delete\u5173\u952e\u5b57\u53ca\u5176\u5e95\u5c42"}]},{"@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\/91734","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=91734"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/91734\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/91727"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=91734"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=91734"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=91734"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=91734"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}