📄 stdexcep.html
字号:
<HTML><HEAD><TITLE><stdexcept></TITLE></HEAD><BODY><H1><A NAME="<stdexcept>"><CODE><stdexcept></CODE></A></H1><HR><P>Include the standard header <B><CODE><stdexcept></CODE></B>to define several classes used for reporting exceptions.The classes form a derivation hierarchy, as indicated by the indentingabove, all derived from class<CODE><A HREF="exceptio.html#exception">exception</A></CODE>.</P><PRE>namespace std {class <B><A HREF="#logic_error">logic_error</A></B>; class <B><A HREF="#domain_error">domain_error</A></B>; class <B><A HREF="#invalid_argument">invalid_argument</A></B>; class <B><A HREF="#length_error">length_error</A></B>; class <B><A HREF="#out_of_range">out_of_range</A></B>;class <B><A HREF="#runtime_error">runtime_error</A></B>; class <B><A HREF="#range_error">range_error</A></B>; class <B><A HREF="#overflow_error">overflow_error</A></B>; class <B><A HREF="#underflow_error">underflow_error</A></B>; };</PRE><H2><A NAME="domain_error"><CODE>domain_error</CODE></A></H2><PRE>class <B>domain_error</B> : public <A HREF="#logic_error">logic_error</A> {public: domain_error(const string& message); };</PRE><P>The class serves as the base class for all exceptions thrownto report a<A HREF="math.html#domain error">domain error</A>. The value returned by<CODE><A HREF="exceptio.html#exception::what">what</A>()</CODE> is a copy of<CODE>message.<A HREF="string2.html#basic_string::data">data</A>()</CODE>.</P><H2><A NAME="invalid_argument"><CODE>invalid_argument</CODE></A></H2><PRE>class <B>invalid_argument</B> : public <A HREF="#logic_error">logic_error</A> {public: invalid_argument(const string& message); };</PRE><P>The class serves as the base class for all exceptions thrownto report an invalid argument. The value returned by<CODE><A HREF="exceptio.html#exception::what">what</A>()</CODE> is a copy of<CODE>message.<A HREF="string2.html#basic_string::data">data</A>()</CODE>.</P><H2><A NAME="length_error"><CODE>length_error</CODE></A></H2><PRE>class <B>length_error</B> : public <A HREF="#logic_error">logic_error</A> {public: <B>length_error</B>(const string& message); };</PRE><P>The class serves as the base class for all exceptions thrownto report an attempt to generate an object too long to be specified.The value returned by<CODE><A HREF="exceptio.html#exception::what">what</A>()</CODE> is a copy of<CODE>message.<A HREF="string2.html#basic_string::data">data</A>()</CODE>.</P><H2><A NAME="logic_error"><CODE>logic_error</CODE></A></H2><PRE>class <B>logic_error</B> : public <A HREF="exceptio.html#exception">exception</A> {public: <B>logic_error</B>(const string& message); };</PRE><P>The class serves as the base class for all exceptions thrownto report errors presumably detectable before the program executes,such as violations of logical preconditions. The value returned by<CODE><A HREF="exceptio.html#exception::what">what</A>()</CODE> is a copy of<CODE>message.<A HREF="string2.html#basic_string::data">data</A>()</CODE>.</P><H2><A NAME="out_of_range"><CODE>out_of_range</CODE></A></H2><PRE>class <B>out_of_range</B> : public <A HREF="#logic_error">logic_error</A> {public: <B>out_of_range</B>(const string& message); };</PRE><P>The class serves as the base class for all exceptions thrownto report an argument that is out of its valid range. The value returned by<CODE><A HREF="exceptio.html#exception::what">what</A>()</CODE> is a copy of<CODE>message.<A HREF="string2.html#basic_string::data">data</A>()</CODE>.</P><H2><A NAME="overflow_error"><CODE>overflow_error</CODE></A></H2><PRE>class <B>overflow_error</B> : public <A HREF="#runtime_error">runtime_error</A> {public: <B>overflow_error</B>(const string& message); };</PRE><P>The class serves as the base class for all exceptions thrownto report an arithmetic overflow. The value returned by<CODE><A HREF="exceptio.html#exception::what">what</A>()</CODE> is a copy of<CODE>message.<A HREF="string2.html#basic_string::data">data</A>()</CODE>.</P><H2><A NAME="range_error"><CODE>range_error</CODE></A></H2><PRE>class <B>range_error</B> : public <A HREF="#runtime_error">runtime_error</A> {public: <B>range_error</B>(const string& message); };</PRE><P>The class serves as the base class for all exceptions thrownto report a<A HREF="math.html#range error">range error</A>. The value returned by<CODE><A HREF="exceptio.html#exception::what">what</A>()</CODE> is a copy of<CODE>message.<A HREF="string2.html#basic_string::data">data</A>()</CODE>.</P><H2><A NAME="runtime_error"><CODE>runtime_error</CODE></A></H2><PRE>class <B>runtime_error</B> : public <A HREF="exceptio.html#exception">exception</A> {public: <B>runtime_error</B>(const string& message); };</PRE><P>The class serves as the base class for all exceptions thrownto report errors presumably detectable only when the program executes.The value returned by<CODE><A HREF="exceptio.html#exception::what">what</A>()</CODE> is a copy of<CODE>message.<A HREF="string2.html#basic_string::data">data</A>()</CODE>.</P><H2><A NAME="underflow_error"><CODE>underflow_error</CODE></A></H2><PRE>class <B>underflow_error</B> : public <A HREF="#runtime_error">runtime_error</A> {public: <B>underflow_error</B>(const string& message); };</PRE><P>The class serves as the base class for all exceptions thrownto report an arithmetic underflow. The value returned by<CODE><A HREF="exceptio.html#exception::what">what</A>()</CODE> is a copy of<CODE>message.<A HREF="string2.html#basic_string::data">data</A>()</CODE>.</P><HR><P>See also the<B><A HREF="index.html#Table of Contents">Table of Contents</A></B> and the<B><A HREF="_index.html">Index</A></B>.</P><P><I><A HREF="crit_pjp.html">Copyright</A> © 1992-2002by P.J. Plauger. All rights reserved.</I></P><!--V4.01:1125--></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -