Files
hustoj/web/cppreference-zh/chmhelp/cpp-error-exception-exception.html
2025-08-01 12:57:54 +08:00

89 lines
5.1 KiB
HTML

<!DOCTYPE html>
<html lang="zh" dir="ltr" class="client-nojs" xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh">
<head><meta http-equiv="x-ua-compatible" content="ie=edge">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>std::exception::exception</title>
<link rel="stylesheet" href="ext.css" />
<link rel="stylesheet" href="site_modules.css" />
</head>
<body class="mediawiki ltr sitedir-ltr ns-0 ns-subject page-cpp_error_exception_exception skin-cppreference2 action-view cpp-navbar">
<div id="cpp-content-base">
<div id="content"><a id="top"></a>
<h1 id="firstHeading" class="firstHeading"><span style="font-size:0.7em; line-height:130%">std::exception::</span>exception</h1>
<div id="bodyContent">
<div id="contentSub"><span class="subpages">&lt; <a href="cpp.html">cpp</a>&lrm; | <a href="cpp-error.html">error</a>&lrm; | <a href="cpp-error-exception.html">exception</a></span></div>
<div id="mw-content-text" lang="zh" dir="ltr" class="mw-content-ltr" xml:lang="zh">
<table class="t-dcl-begin">
<tbody></tbody>
<tbody class="t-dcl-rev t-dcl-rev-num">
<tr class="t-dcl-rev-aux">
<td></td>
<td rowspan="142">(1)</td>
<td></td>
</tr>
<tr class="t-dcl t-until-cxx11">
<td>
<div><span class="mw-geshi cpp source-cpp">exception<span class="br0">(</span><span class="br0">)</span> <span class="kw1">throw</span><span class="br0">(</span><span class="br0">)</span><span class="sy4">;</span></span></div>
</td>
<td class="t-dcl-nopad"></td>
<td><span class="t-mark-rev t-until-cxx11">(C++11 &#21069;)</span></td>
</tr>
<tr class="t-dcl t-since-cxx11">
<td>
<div><span class="mw-geshi cpp source-cpp">exception<span class="br0">(</span><span class="br0">)</span> <span class="kw1">noexcept</span><span class="sy4">;</span></span></div>
</td>
<td class="t-dcl-nopad"></td>
<td><span class="t-mark-rev t-since-cxx11">(C++11 &#36215;)</span></td>
</tr>
</tbody>
<tbody></tbody>
<tbody class="t-dcl-rev t-dcl-rev-num">
<tr class="t-dcl-rev-aux">
<td></td>
<td rowspan="142">(2)</td>
<td></td>
</tr>
<tr class="t-dcl t-until-cxx11">
<td>
<div><span class="mw-geshi cpp source-cpp">exception<span class="br0">(</span> <span class="kw4">const</span> exception<span class="sy3">&amp;</span> other <span class="br0">)</span> <span class="kw1">throw</span><span class="br0">(</span><span class="br0">)</span><span class="sy4">;</span></span></div>
</td>
<td class="t-dcl-nopad"></td>
<td><span class="t-mark-rev t-until-cxx11">(C++11 &#21069;)</span></td>
</tr>
<tr class="t-dcl t-since-cxx11">
<td>
<div><span class="mw-geshi cpp source-cpp">exception<span class="br0">(</span> <span class="kw4">const</span> exception<span class="sy3">&amp;</span> other <span class="br0">)</span> <span class="kw1">noexcept</span><span class="sy4">;</span></span></div>
</td>
<td class="t-dcl-nopad"></td>
<td><span class="t-mark-rev t-since-cxx11">(C++11 &#36215;)</span></td>
</tr>
</tbody>
<tbody>
<tr class="t-dcl-sep">
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<p>&#26500;&#36896;&#26032;&#30340;&#24322;&#24120;&#23545;&#35937;&#12290;</p>
<div class="t-li1"><span class="t-li">1)</span> &#40664;&#35748;&#26500;&#36896;&#20989;&#25968;&#12290; <a href="cpp-error-exception-what.html"><tt>what()</tt></a> &#36820;&#22238;&#23454;&#29616;&#23450;&#20041;&#30340;&#23383;&#31526;&#20018;&#12290;</div>
<div class="t-li1"><span class="t-li">2)</span> &#22797;&#21046;&#26500;&#36896;&#20989;&#25968;&#12290;&#20197; <code>other</code> &#30340;&#20869;&#23481;&#21021;&#22987;&#21270;&#20854;&#20869;&#23481;&#12290;<span class="t-rev-inl t-since-cxx11"><span>&#33509; <code>*this</code> &#19982; <code>other</code> &#22343;&#25317;&#26377;&#21160;&#24577;&#31867;&#22411; <code>std::exception</code> &#65292;&#21017; <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="cpp-string-byte-strcmp.html"><span class="kw1146">std::<span class="me2">strcmp</span></span></a><span class="br0">(</span>what<span class="br0">(</span><span class="br0">)</span>, other.<span class="me1">what</span><span class="br0">(</span><span class="br0">)</span><span class="br0">)</span> <span class="sy1">==</span> <span class="nu0">0</span></span></span> &#12290;</span> <span><span class="t-mark-rev t-since-cxx11">(C++11 &#36215;)</span></span></span></div>
<h3><span class="mw-headline" id=".E5.8F.82.E6.95.B0">&#21442;&#25968;</span></h3>
<table class="t-par-begin">
<tr class="t-par">
<td>other</td>
<td>-</td>
<td>&#35201;&#36171;&#20540;&#20869;&#23481;&#30340;&#21478;&#19968; exception</td>
</tr>
</table>
<h3><span class="mw-headline" id=".E6.B3.A8.E6.84.8F">&#27880;&#24847;</span></h3>
<p>&#22240;&#20026;&#19981;&#20801;&#35768;&#22797;&#21046; <code>std::exception</code> &#25243;&#20986;&#24322;&#24120;&#65292;&#25925;&#24403;&#27966;&#29983;&#31867;&#65288;&#20363;&#22914; <span class="t-lc"><a href="cpp-error-runtime_error.html">std::runtime_error</a></span> &#65289;&#24517;&#39035;&#31649;&#29702;&#29992;&#25143;&#23450;&#20041;&#30340;&#35786;&#26029;&#20449;&#24687;&#26102;&#65292;&#24120;&#23558;&#23427;&#23454;&#29616;&#20026;&#20889;&#26102;&#22797;&#21046;&#30340;&#23383;&#31526;&#20018;&#12290;</p>
</div>
<div class="visualClear"></div>
</div>
</div>
</div>
</body>
</html>