{"id":215,"date":"2023-08-18T18:04:49","date_gmt":"2023-08-18T10:04:49","guid":{"rendered":"http:\/\/blog.xjfvps.top\/index.php\/2023\/08\/18\/%e3%80%8ac%e5%a4%a7%e5%ad%a6%e6%95%99%e7%a8%8b%e3%80%8b%e8%af%bb%e4%b9%a6%e7%ac%94%e8%ae%b0-%ef%bc%88%e7%ac%ac13%e7%ab%a0-%e5%bc%82%e5%b8%b8%e5%a4%84%e7%90%86%ef%bc%89\/"},"modified":"2023-08-18T21:25:32","modified_gmt":"2023-08-18T13:25:32","slug":"%e3%80%8ac%e5%a4%a7%e5%ad%a6%e6%95%99%e7%a8%8b%e3%80%8b%e8%af%bb%e4%b9%a6%e7%ac%94%e8%ae%b0-%ef%bc%88%e7%ac%ac13%e7%ab%a0-%e5%bc%82%e5%b8%b8%e5%a4%84%e7%90%86%ef%bc%89","status":"publish","type":"post","link":"https:\/\/blog.fs.cloudns.biz\/index.php\/2023\/08\/18\/%e3%80%8ac%e5%a4%a7%e5%ad%a6%e6%95%99%e7%a8%8b%e3%80%8b%e8%af%bb%e4%b9%a6%e7%ac%94%e8%ae%b0-%ef%bc%88%e7%ac%ac13%e7%ab%a0-%e5%bc%82%e5%b8%b8%e5%a4%84%e7%90%86%ef%bc%89\/","title":{"rendered":"\u300ac++\u5927\u5b66\u6559\u7a0b\u300b\u8bfb\u4e66\u7b14\u8bb0 \uff08\u7b2c13\u7ae0 \u5f02\u5e38\u5904\u7406\uff09"},"content":{"rendered":"<p><BR>&nbsp;&nbsp; &nbsp;&nbsp; \u8fd9\u4e00\u7ae0\u6240\u4ecb\u7ecd\u7684\u4f3c\u4e4e\u7b80\u7565\u4e86\u4e00\u4e9b\u3002\u5f53\u7136\uff0c\u6211\u4e5f\u4e0d\u77e5\u8be5\u600e\u4e48\u6837\u5199\u624d\u7b97\u8bf4\u5f97\u6e05\u695a\uff0c\u6bd5\u7adf\u6211\u624d\u521d\u5b66C++\uff0c\u53ea\u662f\u770b\u5f97\u6211\u4e0d\u592a\u723d\uff0c\u6709\u4e9b\u5730\u65b9\u4e0d\u660e\u767d\u3002<BR><BR>\u8fd9\u7ae0\u603b\u7684\u6709\u4e24\u70b9\u4e0d\u8db3\uff1a1.\u8bf4\u5f97\u4e0d\u591f\u6df1\u5165\u30022.\u4f8b\u5b50\u4e0d\u591f\u7cbe\u8f9f\u3002<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \u5176\u4e2d\u6709\u4e2a\u4f8b\u5b50\uff08\u56e0\u4e3a\u5185\u5b58\u6bd4\u8f83\u5927\uff0c\u505a\u4e86\u70b9\u4fee\u6539\uff09\u6211\u5728\u4e0a\u673a\u7684\u65f6\u5019\u5c31\u53d1\u751f\u9519\u8bef\uff0cabort\u4e86\u3002\u4e00\u5f00\u59cb\u5c31new\u5931\u8d25\u3002\uff08VC6.0)<BR><br \/>\n<DIV style=\"BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 4px; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: windowtext 0.5pt solid\"><br \/>\n<DIV><IMG src=\"\/Images\/OutliningIndicators\/None.gif\" align=top><SPAN style=\"COLOR: #000000\">#include&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">&lt;<\/SPAN><SPAN style=\"COLOR: #000000\">iostream<\/SPAN><SPAN style=\"COLOR: #000000\">&gt;<\/SPAN><SPAN style=\"COLOR: #000000\"><BR><IMG src=\"\/Images\/OutliningIndicators\/None.gif\" align=top>#include&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">&lt;<\/SPAN><SPAN style=\"COLOR: #0000ff\">new<\/SPAN><SPAN style=\"COLOR: #000000\">&gt;<\/SPAN><SPAN style=\"COLOR: #000000\"><BR><IMG src=\"\/Images\/OutliningIndicators\/None.gif\" align=top><\/SPAN><SPAN style=\"COLOR: #0000ff\">using<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #0000ff\">namespace<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;std;<BR><IMG src=\"\/Images\/OutliningIndicators\/None.gif\" align=top><BR><IMG src=\"\/Images\/OutliningIndicators\/None.gif\" align=top><BR><IMG src=\"\/Images\/OutliningIndicators\/None.gif\" align=top><\/SPAN><SPAN style=\"COLOR: #0000ff\">void<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;customNewHandler()<BR><IMG id=Codehighlighter1_82_133_Open_Image onclick=\"this.style.display='none'; Codehighlighter1_82_133_Open_Text.style.display='none'; Codehighlighter1_82_133_Closed_Image.style.display='inline'; Codehighlighter1_82_133_Closed_Text.style.display='inline';\" src=\"\/Images\/OutliningIndicators\/ExpandedBlockStart.gif\" align=top><IMG id=Codehighlighter1_82_133_Closed_Image style=\"DISPLAY: none\" onclick=\"this.style.display='none'; Codehighlighter1_82_133_Closed_Text.style.display='none'; Codehighlighter1_82_133_Open_Image.style.display='inline'; Codehighlighter1_82_133_Open_Text.style.display='inline';\" src=\"\/Images\/OutliningIndicators\/ContractedBlock.gif\" align=top><\/SPAN><SPAN id=Codehighlighter1_82_133_Closed_Text style=\"BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff\"><\/SPAN><SPAN id=Codehighlighter1_82_133_Open_Text><SPAN style=\"COLOR: #000000\">{<BR><IMG src=\"\/Images\/OutliningIndicators\/InBlock.gif\" align=top>&nbsp;&nbsp;&nbsp;&nbsp;cerr<\/SPAN><SPAN style=\"COLOR: #000000\">&lt;&lt;<\/SPAN><SPAN style=\"COLOR: #000000\">&#8220;<\/SPAN><SPAN style=\"COLOR: #000000\">customNewHandler&nbsp;was&nbsp;called&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">&#8220;<\/SPAN><SPAN style=\"COLOR: #000000\"&gt;;<BR><IMG src=\"\/Images\/OutliningIndicators\/InBlock.gif\" align=top>&nbsp;&nbsp;&nbsp;&nbsp;abort();<BR><IMG src=\"\/Images\/OutliningIndicators\/ExpandedBlockEnd.gif\" align=top>}<\/SPAN><\/SPAN><SPAN style=\"COLOR: #000000\"><BR><IMG src=\"\/Images\/OutliningIndicators\/None.gif\" align=top><BR><IMG src=\"\/Images\/OutliningIndicators\/None.gif\" align=top><\/SPAN><SPAN style=\"COLOR: #0000ff\">int<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;main()<BR><IMG id=Codehighlighter1_147_348_Open_Image onclick=\"this.style.display='none'; Codehighlighter1_147_348_Open_Text.style.display='none'; Codehighlighter1_147_348_Closed_Image.style.display='inline'; Codehighlighter1_147_348_Closed_Text.style.display='inline';\" src=\"\/Images\/OutliningIndicators\/ExpandedBlockStart.gif\" align=top><IMG id=Codehighlighter1_147_348_Closed_Image style=\"DISPLAY: none\" onclick=\"this.style.display='none'; Codehighlighter1_147_348_Closed_Text.style.display='none'; Codehighlighter1_147_348_Open_Image.style.display='inline'; Codehighlighter1_147_348_Open_Text.style.display='inline';\" src=\"\/Images\/OutliningIndicators\/ContractedBlock.gif\" align=top><\/SPAN><SPAN id=Codehighlighter1_147_348_Closed_Text style=\"BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff\"><\/SPAN><SPAN id=Codehighlighter1_147_348_Open_Text><SPAN style=\"COLOR: #000000\">{<BR><IMG src=\"\/Images\/OutliningIndicators\/InBlock.gif\" align=top>&nbsp;&nbsp;&nbsp;&nbsp;<\/SPAN><SPAN style=\"COLOR: #0000ff\">double<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">*<\/SPAN><SPAN style=\"COLOR: #000000\">ptr[<\/SPAN><SPAN style=\"COLOR: #000000\">9999<\/SPAN><SPAN style=\"COLOR: #000000\"&gt;];<BR><IMG src=\"\/Images\/OutliningIndicators\/InBlock.gif\" align=top>&nbsp;&nbsp;&nbsp;&nbsp;set_new_handler(customNewHandler);<BR><IMG src=\"\/Images\/OutliningIndicators\/InBlock.gif\" align=top><BR><IMG src=\"\/Images\/OutliningIndicators\/InBlock.gif\" align=top>&nbsp;&nbsp;&nbsp;&nbsp;<BR><IMG src=\"\/Images\/OutliningIndicators\/InBlock.gif\" align=top><BR><IMG src=\"\/Images\/OutliningIndicators\/InBlock.gif\" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/SPAN><SPAN style=\"COLOR: #0000ff\">for<\/SPAN><SPAN style=\"COLOR: #000000\">(<\/SPAN><SPAN style=\"COLOR: #0000ff\">int<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;i<\/SPAN><SPAN style=\"COLOR: #000000\">=<\/SPAN><SPAN style=\"COLOR: #000000\">0<\/SPAN><SPAN style=\"COLOR: #000000\"&gt;;&nbsp;i<\/SPAN><SPAN style=\"COLOR: #000000\">&lt;9999<\/SPAN><SPAN style=\"COLOR: #000000\"&gt;;&nbsp;i<\/SPAN><SPAN style=\"COLOR: #000000\">++<\/SPAN><SPAN style=\"COLOR: #000000\">)<BR><IMG id=Codehighlighter1_235_329_Open_Image onclick=\"this.style.display='none'; Codehighlighter1_235_329_Open_Text.style.display='none'; Codehighlighter1_235_329_Closed_Image.style.display='inline'; Codehighlighter1_235_329_Closed_Text.style.display='inline';\" src=\"\/Images\/OutliningIndicators\/ExpandedSubBlockStart.gif\" align=top><IMG id=Codehighlighter1_235_329_Closed_Image style=\"DISPLAY: none\" onclick=\"this.style.display='none'; Codehighlighter1_235_329_Closed_Text.style.display='none'; Codehighlighter1_235_329_Open_Image.style.display='inline'; Codehighlighter1_235_329_Open_Text.style.display='inline';\" src=\"\/Images\/OutliningIndicators\/ContractedSubBlock.gif\" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/SPAN><SPAN id=Codehighlighter1_235_329_Open_Text><SPAN style=\"COLOR: #000000\">{<BR><IMG src=\"\/Images\/OutliningIndicators\/InBlock.gif\" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ptr[i]<\/SPAN><SPAN style=\"COLOR: #000000\">=<\/SPAN><SPAN style=\"COLOR: #0000ff\">new<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #0000ff\">double<\/SPAN><SPAN style=\"COLOR: #000000\">[<\/SPAN><SPAN style=\"COLOR: #000000\">5000000<\/SPAN><SPAN style=\"COLOR: #000000\"&gt;];<BR><IMG src=\"\/Images\/OutliningIndicators\/InBlock.gif\" align=top><BR><IMG src=\"\/Images\/OutliningIndicators\/InBlock.gif\" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout<\/SPAN><SPAN style=\"COLOR: #000000\">&lt;&lt;<\/SPAN><SPAN style=\"COLOR: #000000\">&#8220;<\/SPAN><SPAN style=\"COLOR: #000000\">Allocated&nbsp;5000000&nbsp;double&nbsp;s&nbsp;in&nbsp;ptr[<\/SPAN><SPAN style=\"COLOR: #000000\">&#8220;<\/SPAN><SPAN style=\"COLOR: #000000\">&lt;&lt;<\/SPAN><SPAN style=\"COLOR: #000000\">i<\/SPAN><SPAN style=\"COLOR: #000000\">&lt;&lt;<\/SPAN><SPAN style=\"COLOR: #000000\">&#8220;<\/SPAN><SPAN style=\"COLOR: #000000\">]n<\/SPAN><SPAN style=\"COLOR: #000000\">&#8220;<\/SPAN><SPAN style=\"COLOR: #000000\"&gt;;<BR><IMG src=\"\/Images\/OutliningIndicators\/ExpandedSubBlockEnd.gif\" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<\/SPAN><\/SPAN><SPAN style=\"COLOR: #000000\"><BR><IMG src=\"\/Images\/OutliningIndicators\/InBlock.gif\" align=top>&nbsp;&nbsp;&nbsp;&nbsp;<BR><IMG src=\"\/Images\/OutliningIndicators\/InBlock.gif\" align=top><BR><IMG src=\"\/Images\/OutliningIndicators\/InBlock.gif\" align=top><BR><IMG src=\"\/Images\/OutliningIndicators\/InBlock.gif\" align=top><BR><IMG src=\"\/Images\/OutliningIndicators\/InBlock.gif\" align=top>&nbsp;&nbsp;&nbsp;&nbsp;<\/SPAN><SPAN style=\"COLOR: #0000ff\">return<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">0<\/SPAN><SPAN style=\"COLOR: #000000\"&gt;;<BR><IMG src=\"\/Images\/OutliningIndicators\/InBlock.gif\" align=top><BR><IMG src=\"\/Images\/OutliningIndicators\/ExpandedBlockEnd.gif\" align=top>}<\/SPAN><\/SPAN><\/DIV><\/DIV><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \u8ddf\u8e2a\u4e00\u4e0b\uff0c\u53d1\u73b0\u5728set_new_handler(customNewHandler)\u5c31\u51fa\u9519\u4e86\u3002\u4f46\u7528VC7\u548cgcc\u7f16\u8bd1\u540e\u8fd0\u884c\u6b63\u5e38\uff0c\u7ed3\u679c\u5747\u5982\u4e0b\uff1a<BR><SPAN style=\"COLOR: #3366ff\">Allocated 5000000 double s in ptr[0]<BR>Allocated 5000000 double s in ptr[1]<BR>Allocated 5000000 double s in ptr[2]<BR>Allocated 5000000 double s in ptr[3]<BR>Allocated 5000000 double s in ptr[4]<BR>Allocated 5000000 double s in ptr[5]<BR>Allocated 5000000 double s in ptr[6]<BR>Allocated 5000000 double s in ptr[7]<BR>Allocated 5000000 double s in ptr[8]<BR>Allocated 5000000 double s in ptr[9]<BR>Allocated 5000000 double s in ptr[10]<BR>Allocated 5000000 double s in ptr[11]<BR>Allocated 5000000 double s in ptr[12]<BR>Allocated 5000000 double s in ptr[13]<BR>Allocated 5000000 double s in ptr[14]<BR>Allocated 5000000 double s in ptr[15]<BR>Allocated 5000000 double s in ptr[16]<BR>Allocated 5000000 double s in ptr[17]<BR>Allocated 5000000 double s in ptr[18]<BR>Allocated 5000000 double s in ptr[19]<BR>Allocated 5000000 double s in ptr[20]<BR>Allocated 5000000 double s in ptr[21]<BR>Allocated 5000000 double s in ptr[22]<BR>Allocated 5000000 double s in ptr[23]<BR>Allocated 5000000 double s in ptr[24]<BR>Allocated 5000000 double s in ptr[25]<BR>Allocated 5000000 double s in ptr[26]<BR>Allocated 5000000 double s in ptr[27]<BR>customNewHandler was called<BR><\/SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp; \u53e6\u4e00\u4e2a\u4f8b\u5b50\u662f\u6d4b\u8bd5new\u6545\u969c\u629b\u51fabad_alloc\u5f02\u5e38\u3002<BR><br \/>\n<DIV style=\"BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 4px; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: windowtext 0.5pt solid\"><br \/>\n<DIV><IMG src=\"\/Images\/OutliningIndicators\/None.gif\" align=top><SPAN style=\"COLOR: #000000\">#include&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">&lt;<\/SPAN><SPAN style=\"COLOR: #000000\">iostream<\/SPAN><SPAN style=\"COLOR: #000000\">&gt;<\/SPAN><SPAN style=\"COLOR: #000000\"><BR><IMG src=\"\/Images\/OutliningIndicators\/None.gif\" align=top>#include&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">&lt;<\/SPAN><SPAN style=\"COLOR: #0000ff\">new<\/SPAN><SPAN style=\"COLOR: #000000\">&gt;<\/SPAN><SPAN style=\"COLOR: #000000\"><BR><IMG src=\"\/Images\/OutliningIndicators\/None.gif\" align=top><\/SPAN><SPAN style=\"COLOR: #0000ff\">using<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #0000ff\">namespace<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;std;<BR><IMG src=\"\/Images\/OutliningIndicators\/None.gif\" align=top><BR><IMG src=\"\/Images\/OutliningIndicators\/None.gif\" align=top><BR><IMG src=\"\/Images\/OutliningIndicators\/None.gif\" align=top><\/SPAN><SPAN style=\"COLOR: #0000ff\">int<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;main()<BR><IMG id=Codehighlighter1_69_322_Open_Image onclick=\"this.style.display='none'; Codehighlighter1_69_322_Open_Text.style.display='none'; Codehighlighter1_69_322_Closed_Image.style.display='inline'; Codehighlighter1_69_322_Closed_Text.style.display='inline';\" src=\"\/Images\/OutliningIndicators\/ExpandedBlockStart.gif\" align=top><IMG id=Codehighlighter1_69_322_Closed_Image style=\"DISPLAY: none\" onclick=\"this.style.display='none'; Codehighlighter1_69_322_Closed_Text.style.display='none'; Codehighlighter1_69_322_Open_Image.style.display='inline'; Codehighlighter1_69_322_Open_Text.style.display='inline';\" src=\"\/Images\/OutliningIndicators\/ContractedBlock.gif\" align=top><\/SPAN><SPAN id=Codehighlighter1_69_322_Closed_Text style=\"BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff\"><IMG src=\"\/Images\/dot.gif\"><\/SPAN><SPAN id=Codehighlighter1_69_322_Open_Text><SPAN style=\"COLOR: #000000\">{<BR><IMG src=\"\/Images\/OutliningIndicators\/InBlock.gif\" align=top>&nbsp;&nbsp;&nbsp;&nbsp;<\/SPAN><SPAN style=\"COLOR: #0000ff\">double<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">*<\/SPAN><SPAN style=\"COLOR: #000000\">ptr[<\/SPAN><SPAN style=\"COLOR: #000000\">9999<\/SPAN><SPAN style=\"COLOR: #000000\"&gt;];<BR><IMG src=\"\/Images\/OutliningIndicators\/InBlock.gif\" align=top><BR><IMG src=\"\/Images\/OutliningIndicators\/InBlock.gif\" align=top><BR><IMG src=\"\/Images\/OutliningIndicators\/InBlock.gif\" align=top>&nbsp;&nbsp;&nbsp;&nbsp;<\/SPAN><SPAN style=\"COLOR: #0000ff\">try<\/SPAN><SPAN style=\"COLOR: #000000\"><BR><IMG id=Codehighlighter1_97_226_Open_Image onclick=\"this.style.display='none'; Codehighlighter1_97_226_Open_Text.style.display='none'; Codehighlighter1_97_226_Closed_Image.style.display='inline'; Codehighlighter1_97_226_Closed_Text.style.display='inline';\" src=\"\/Images\/OutliningIndicators\/ExpandedSubBlockStart.gif\" align=top><IMG id=Codehighlighter1_97_226_Closed_Image style=\"DISPLAY: none\" onclick=\"this.style.display='none'; Codehighlighter1_97_226_Closed_Text.style.display='none'; Codehighlighter1_97_226_Open_Image.style.display='inline'; Codehighlighter1_97_226_Open_Text.style.display='inline';\" src=\"\/Images\/OutliningIndicators\/ContractedSubBlock.gif\" align=top>&nbsp;&nbsp;&nbsp;&nbsp;<\/SPAN><SPAN id=Codehighlighter1_97_226_Closed_Text style=\"BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff\"><IMG src=\"\/Images\/dot.gif\"><\/SPAN><SPAN id=Codehighlighter1_97_226_Open_Text><SPAN style=\"COLOR: #000000\">{<BR><IMG src=\"\/Images\/OutliningIndicators\/InBlock.gif\" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/SPAN><SPAN style=\"COLOR: #0000ff\">for<\/SPAN><SPAN style=\"COLOR: #000000\">(<\/SPAN><SPAN style=\"COLOR: #0000ff\">int<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;i<\/SPAN><SPAN style=\"COLOR: #000000\">=<\/SPAN><SPAN style=\"COLOR: #000000\">0<\/SPAN><SPAN style=\"COLOR: #000000\"&gt;;&nbsp;i<\/SPAN><SPAN style=\"COLOR: #000000\">&lt;<\/SPAN><SPAN style=\"COLOR: #000000\">9999<\/SPAN><SPAN style=\"COLOR: #000000\"&gt;;&nbsp;i<\/SPAN><SPAN style=\"COLOR: #000000\">++<\/SPAN><SPAN style=\"COLOR: #000000\">)<BR><IMG id=Codehighlighter1_129_223_Open_Image onclick=\"this.style.display='none'; Codehighlighter1_129_223_Open_Text.style.display='none'; Codehighlighter1_129_223_Closed_Image.style.display='inline'; Codehighlighter1_129_223_Closed_Text.style.display='inline';\" src=\"\/Images\/OutliningIndicators\/ExpandedSubBlockStart.gif\" align=top><IMG id=Codehighlighter1_129_223_Closed_Image style=\"DISPLAY: none\" onclick=\"this.style.display='none'; Codehighlighter1_129_223_Closed_Text.style.display='none'; Codehighlighter1_129_223_Open_Image.style.display='inline'; Codehighlighter1_129_223_Open_Text.style.display='inline';\" src=\"\/Images\/OutliningIndicators\/ContractedSubBlock.gif\" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/SPAN><SPAN id=Codehighlighter1_129_223_Closed_Text style=\"BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff\"><IMG src=\"\/Images\/dot.gif\"><\/SPAN><SPAN id=Codehighlighter1_129_223_Open_Text><SPAN style=\"COLOR: #000000\">{<BR><IMG src=\"\/Images\/OutliningIndicators\/InBlock.gif\" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ptr[i]<\/SPAN><SPAN style=\"COLOR: #000000\">=<\/SPAN><SPAN style=\"COLOR: #0000ff\">new<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #0000ff\">double<\/SPAN><SPAN style=\"COLOR: #000000\">[<\/SPAN><SPAN style=\"COLOR: #000000\">5000000<\/SPAN><SPAN style=\"COLOR: #000000\"&gt;];<BR><IMG src=\"\/Images\/OutliningIndicators\/InBlock.gif\" align=top><BR><IMG src=\"\/Images\/OutliningIndicators\/InBlock.gif\" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout<\/SPAN><SPAN style=\"COLOR: #000000\">&lt;&lt;<\/SPAN><SPAN style=\"COLOR: #000000\">&#8220;<\/SPAN><SPAN style=\"COLOR: #000000\">Allocated&nbsp;5000000&nbsp;double&nbsp;s&nbsp;in&nbsp;ptr[<\/SPAN><SPAN style=\"COLOR: #000000\">&#8220;<\/SPAN><SPAN style=\"COLOR: #000000\">&lt;&lt;<\/SPAN><SPAN style=\"COLOR: #000000\">i<\/SPAN><SPAN style=\"COLOR: #000000\">&lt;&lt;<\/SPAN><SPAN style=\"COLOR: #000000\">&#8220;<\/SPAN><SPAN style=\"COLOR: #000000\">]n<\/SPAN><SPAN style=\"COLOR: #000000\">&#8220;<\/SPAN><SPAN style=\"COLOR: #000000\"&gt;;<BR><IMG src=\"\/Images\/OutliningIndicators\/ExpandedSubBlockEnd.gif\" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<\/SPAN><\/SPAN><SPAN style=\"COLOR: #000000\"><BR><IMG src=\"\/Images\/OutliningIndicators\/ExpandedSubBlockEnd.gif\" align=top>&nbsp;&nbsp;&nbsp;&nbsp;}<\/SPAN><\/SPAN><SPAN style=\"COLOR: #000000\"><BR><IMG src=\"\/Images\/OutliningIndicators\/InBlock.gif\" align=top>&nbsp;&nbsp;&nbsp;&nbsp;<\/SPAN><SPAN style=\"COLOR: #0000ff\">catch<\/SPAN><SPAN style=\"COLOR: #000000\">(bad_alloc&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">&amp;<\/SPAN><SPAN style=\"COLOR: #000000\">ex)<BR><IMG id=Codehighlighter1_251_306_Open_Image onclick=\"this.style.display='none'; Codehighlighter1_251_306_Open_Text.style.display='none'; Codehighlighter1_251_306_Closed_Image.style.display='inline'; Codehighlighter1_251_306_Closed_Text.style.display='inline';\" src=\"\/Images\/OutliningIndicators\/ExpandedSubBlockStart.gif\" align=top><IMG id=Codehighlighter1_251_306_Closed_Image style=\"DISPLAY: none\" onclick=\"this.style.display='none'; Codehighlighter1_251_306_Closed_Text.style.display='none'; Codehighlighter1_251_306_Open_Image.style.display='inline'; Codehighlighter1_251_306_Open_Text.style.display='inline';\" src=\"\/Images\/OutliningIndicators\/ContractedSubBlock.gif\" align=top>&nbsp;&nbsp;&nbsp;&nbsp;<\/SPAN><SPAN id=Codehighlighter1_251_306_Closed_Text style=\"BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff\"><IMG src=\"\/Images\/dot.gif\"><\/SPAN><SPAN id=Codehighlighter1_251_306_Open_Text><SPAN style=\"COLOR: #000000\">{<BR><IMG src=\"\/Images\/OutliningIndicators\/InBlock.gif\" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout<\/SPAN><SPAN style=\"COLOR: #000000\">&lt;&lt;<\/SPAN><SPAN style=\"COLOR: #000000\">&#8220;<\/SPAN><SPAN style=\"COLOR: #000000\">Exception&nbsp;occurred:<\/SPAN><SPAN style=\"COLOR: #000000\">&#8220;<\/SPAN><SPAN style=\"COLOR: #000000\"><BR><IMG src=\"\/Images\/OutliningIndicators\/InBlock.gif\" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">&lt;&lt;<\/SPAN><SPAN style=\"COLOR: #000000\">ex.what()<\/SPAN><SPAN style=\"COLOR: #000000\">&lt;&lt;<\/SPAN><SPAN style=\"COLOR: #000000\">endl;<BR><IMG src=\"\/Images\/OutliningIndicators\/ExpandedSubBlockEnd.gif\" align=top>&nbsp;&nbsp;&nbsp;&nbsp;}<\/SPAN><\/SPAN><SPAN style=\"COLOR: #000000\"><BR><IMG src=\"\/Images\/OutliningIndicators\/InBlock.gif\" align=top><BR><IMG src=\"\/Images\/OutliningIndicators\/InBlock.gif\" align=top><BR><IMG src=\"\/Images\/OutliningIndicators\/InBlock.gif\" align=top>&nbsp;&nbsp;&nbsp;&nbsp;<\/SPAN><SPAN style=\"COLOR: #0000ff\">return<\/SPAN><SPAN style=\"COLOR: #000000\">&nbsp;<\/SPAN><SPAN style=\"COLOR: #000000\">0<\/SPAN><SPAN style=\"COLOR: #000000\"&gt;;<BR><IMG src=\"\/Images\/OutliningIndicators\/InBlock.gif\" align=top><BR><IMG src=\"\/Images\/OutliningIndicators\/ExpandedBlockEnd.gif\" align=top>}<\/SPAN><\/SPAN><SPAN style=\"COLOR: #000000\"><BR><IMG src=\"\/Images\/OutliningIndicators\/None.gif\" align=top><\/SPAN><\/DIV><\/DIV><br \/>\n<P><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \u5728VC6.0\u7f16\u8bd1\u8fd0\u884c\u65f6\uff0c\u4e0d\u77e5\u8bf4\u5b83\u806a\u660e\u8fd8\u662f\u50bb\uff0c\u7adf\u7136\u5206\u914d\u52309998\u4e2a\u6570\u7ec4\uff0c\u7528\u4e86\u7cfb\u7edf\u865a\u62df\u5185\u5b58\u3002\u6240\u4ee5\u770b\u4e0d\u5230\u629b\u51fa\u5f02\u5e38\u7684\u7ed3\u679c\u3002<BR><BR>\u800c\u5728gcc\u548cVC7\u4e0a\u90fd\u5f97\u5230\u6ee1\u610f\u7b54\u6848\u3002gcc\u7ed3\u679c\u5982\u4e0b\uff1a<BR><BR><SPAN style=\"COLOR: #3366ff\">Allocated 5000000 double s in ptr[0]<BR>Allocated 5000000 double s in ptr[1]<BR>Allocated 5000000 double s in ptr[2]<BR>Allocated 5000000 double s in ptr[3]<BR>Allocated 5000000 double s in ptr[4]<BR>Allocated 5000000 double s in ptr[5]<BR>Allocated 5000000 double s in ptr[6]<BR>Allocated 5000000 double s in ptr[7]<BR>Allocated 5000000 double s in ptr[8]<BR>Allocated 5000000 double s in ptr[9]<BR>Allocated 5000000 double s in ptr[10]<BR>Allocated 5000000 double s in ptr[11]<BR>Allocated 5000000 double s in ptr[12]<BR>Allocated 5000000 double s in ptr[13]<BR>Allocated 5000000 double s in ptr[14]<BR>Allocated 5000000 double s in ptr[15]<BR>Allocated 5000000 double s in ptr[16]<BR>Allocated 5000000 double s in ptr[17]<BR>Allocated 5000000 double s in ptr[18]<BR>Allocated 5000000 double s in ptr[19]<BR>Allocated 5000000 double s in ptr[20]<BR>Allocated 5000000 double s in ptr[21]<BR>Allocated 5000000 double s in ptr[22]<BR>Allocated 5000000 double s in ptr[23]<BR>Allocated 5000000 double s in ptr[24]<BR>Allocated 5000000 double s in ptr[25]<BR>Allocated 5000000 double s in ptr[26]<BR>Allocated 5000000 double s in ptr[27]<BR>Exception occurred:St9bad_alloc<\/SPAN><\/P><br \/>\n<P>&nbsp; VC7\u7ed3\u679c\u5982\u4e0b\uff1a<BR><SPAN style=\"COLOR: #3366ff\">Allocated 5000000 double s in ptr[0]<BR>Allocated 5000000 double s in ptr[1]<BR>Allocated 5000000 double s in ptr[2]<BR>Allocated 5000000 double s in ptr[3]<BR>Allocated 5000000 double s in ptr[4]<BR>Allocated 5000000 double s in ptr[5]<BR>Allocated 5000000 double s in ptr[6]<BR>Allocated 5000000 double s in ptr[7]<BR>Allocated 5000000 double s in ptr[8]<BR>Allocated 5000000 double s in ptr[9]<BR>Allocated 5000000 double s in ptr[10]<BR>Allocated 5000000 double s in ptr[11]<BR>Allocated 5000000 double s in ptr[12]<BR>Allocated 5000000 double s in ptr[13]<BR>Allocated 5000000 double s in ptr[14]<BR>Allocated 5000000 double s in ptr[15]<BR>Allocated 5000000 double s in ptr[16]<BR>Allocated 5000000 double s in ptr[17]<BR>Allocated 5000000 double s in ptr[18]<BR>Allocated 5000000 double s in ptr[19]<BR>Allocated 5000000 double s in ptr[20]<BR>Allocated 5000000 double s in ptr[21]<BR>Allocated 5000000 double s in ptr[22]<BR>Allocated 5000000 double s in ptr[23]<BR>Allocated 5000000 double s in ptr[24]<BR>Allocated 5000000 double s in ptr[25]<BR>Allocated 5000000 double s in ptr[26]<BR>Allocated 5000000 double s in ptr[27]<BR>Exception occurred:bad allocation<\/SPAN><BR><\/P><br \/>\n<P><BR><STRONG>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u4e00\u4e9b\u57fa\u672c\u6982\u5ff5<BR><\/STRONG><SPAN style=\"COLOR: #0000ff\">\u5f02\u5e38\u53ef\u4ee5\u5904\u7406\u7684\u60c5\u51b5\uff1a<\/SPAN><BR>1\u3002\u5185\u5b58\u4e0d\u8db3\u4ee5\u6ee1\u8db3new\u8bf7\u6c42<BR>2\u3002\u6570\u7ec4\u4e0b\u6807\u8d8a\u754c\u3002<BR>3\u3002\u8fd0\u7b97\u6ea2\u51fa<BR>4\u3002\u9664\u6570\u4e3a0<BR>5\u3002\u65e0\u6548\u51fd\u6570\u53c2\u6570<BR><BR><SPAN style=\"COLOR: #0000ff\">\u4e0d\u53ef\u4ee5\u5904\u7406\u60c5\u51b5\uff1a<\/SPAN><BR>1\u3002\u78c1\u76d8I\/O\u5b8c\u6210<BR>2\u3002\u7f51\u7edc\u6d88\u606f\u9001\u8fbe<BR>3\u3002\u9f20\u6807\u5355\u51fb<BR>4\u3002\u7b49\u7b49\u3002\u3002\u3002<BR><BR>C++\u5f02\u5e38\u5904\u7406\u5173\u952e\u5b57\uff1a try\u3001throw\u3001catch<BR><BR>\u7b80\u5355\u5904\u7406\u4f8b\u5b50\uff1a\u9664\u6570\u4e3a0<BR><BR><BR><BR><\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp;&nbsp; &nbsp;&nbsp; \u8fd9\u4e00\u7ae0\u6240\u4ecb\u7ecd\u7684\u4f3c\u4e4e\u7b80\u7565\u4e86\u4e00\u4e9b &hellip; <a href=\"https:\/\/blog.fs.cloudns.biz\/index.php\/2023\/08\/18\/%e3%80%8ac%e5%a4%a7%e5%ad%a6%e6%95%99%e7%a8%8b%e3%80%8b%e8%af%bb%e4%b9%a6%e7%ac%94%e8%ae%b0-%ef%bc%88%e7%ac%ac13%e7%ab%a0-%e5%bc%82%e5%b8%b8%e5%a4%84%e7%90%86%ef%bc%89\/\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,8,1],"tags":[14],"class_list":["post-215","post","type-post","status-publish","format-standard","hentry","category-c","category-8","category-uncategorized","tag-c"],"_links":{"self":[{"href":"https:\/\/blog.fs.cloudns.biz\/index.php\/wp-json\/wp\/v2\/posts\/215","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.fs.cloudns.biz\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.fs.cloudns.biz\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.fs.cloudns.biz\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.fs.cloudns.biz\/index.php\/wp-json\/wp\/v2\/comments?post=215"}],"version-history":[{"count":1,"href":"https:\/\/blog.fs.cloudns.biz\/index.php\/wp-json\/wp\/v2\/posts\/215\/revisions"}],"predecessor-version":[{"id":342,"href":"https:\/\/blog.fs.cloudns.biz\/index.php\/wp-json\/wp\/v2\/posts\/215\/revisions\/342"}],"wp:attachment":[{"href":"https:\/\/blog.fs.cloudns.biz\/index.php\/wp-json\/wp\/v2\/media?parent=215"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.fs.cloudns.biz\/index.php\/wp-json\/wp\/v2\/categories?post=215"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.fs.cloudns.biz\/index.php\/wp-json\/wp\/v2\/tags?post=215"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}