⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 except.htm

📁 这是关于VC++中的STL容器的资料,包括了STL容器各个类之间关系以及类的说明
💻 HTM
字号:
<html>
<head>
<title> The exception Class</title>
</head>

<body bgcolor="#FFFFFF">

<p>
<img src="lego1.gif" align=right>
<img src="ioshead2.gif">
</p>

<pre>
<font size=5 color=green>Class Name</font>        exception

Classification    Error Handling

Header File       &lt;exception&gt;
</pre>
<a href="except.htm#diagram">Class Relationship Diagram</a><br>
<br>
<a href="except.htm#desc">Class Description</a><br>

<h2>Member Classes</h2>

<i>None</i>

<h1>Methods</h1>

<a href="except.htm#exception1">exception() throw();</a><br>
<a href="except.htm#exception2">exception(const exception&) throw();</a><br>
<a href="except.htm#exception3">virtual ~exception() throw();</a><br>
<a href="except.htm#what">virtual const char* what() const throw();</a><br>

<h2>Operators</h2>

<a href="except.htm#operator=">exception& operator=(const exception&) throw();</a><br>

<a href="except.htm#example"><h2>Example</h2></a>
                  
<a name="desc"><h3>Description</h3></a>       

<p>
The  exception class is the base class  for the  logic_error and runtime_error
family of classes.  It is also the base class for <i>bad_alloc</i>, <i>bad_case,</i> <i>bad_exception,</i>
<i>bad_typeid,</i> and <i>ios_base::failure.</i>   The standard C++ library uses the exception  family
of classes to report errors that occur in the execution of   some of the  methods within
the  class library. Exception  objects  are not thrown by all  methods in the standard
class library.  Furthermore Exception class objects are not used  at all to report
errors in the standard library functions that come from the C standard library.
</p>
<hr>
<pre>

<a name="exception1">Method            exception()</a>

Access            Public

Classification    Constructor

Syntax            exception throw();      

Parameters        None

Return            None
</pre>

<h3>Description</h3>
               
<p>
This exception() method  constructs an object of type exception.
</p> 
<hr>
<pre>
<a name="exception2">Method            exception()</a>

Access            Public

Classification    Constructor

Syntax            exception(const exception &X) throw();      

Parameters        X is an exception class that will be used in a copy operation.

Return            None
</pre>


<h3>Description</h3>
<p>
This exception() method is  used  whenever  copies or temporary copies of objects of this
type are needed.  This method is called  whenever an object of this type is:
<pre>
			passed by value
			used as a return type by value
			used to initialize another object of this type
</pre>
</p>
<hr>
<pre> 

<a name="exception3">Method            exception()</a>

Access            Public

Classification    Destructor

Syntax            virtual ~exception() throw();      

Parameters        None

Return            None
</pre>


<h3>Description</h3>
<p>  
This method destroys an object of this type.  Since this method is virtual it may be overridden
in a derived class.
</p>
<hr>
<pre>
<a name="what">Method            what()</a>

Access            Public

Classification    Destructor

Syntax            virtual const char* what() const throw()      

Parameters        None

Return            The what() method returns a description or explanation for the exception
                  that was thrown.
</pre>

<h3>Description</h3>
<p>
This method returns a description of the  error that  objects of this class report.
This method can also be used to return explanations as well as possible corrective
steps.
</p>
<hr>
<pre>

<a name="operator=">Method            operator=()</a>

Access            Public

Classification    Operator

Syntax            exception& operator=(const exception &X) throw();      

Parameters        X is an exception object that will be copied into the
                  current exception object.

Return            The assignment operator returns a reference to the current
                  object.
</pre>

<h3>Description</h3>
<p>
This  definition of the  assignment operator assigns  X to the current exception object.
</p>
<hr>
<a name="diagram"><img src="except.gif"></a>
<a name="example"></a>
<img src="lego.gif">
<pre>

    1   
    2   #include &lt;exception&gt;
    3   
    4   
    5   void main(void)
    6   {
    7   
    8   
    9      try{
   10   
   11            exception X;
   12            throw(X);
   13      }
   14      catch(const exception &X)
   15      {
   16          cout &lt;&lt; X.what() &lt;&lt; endl;
   17   
   18      }
   19   
   20      try
   21      {      
   22          logic_error Logic("Logic Mistake");
   23          throw(Logic);
   24      }
   25      catch(const exception &X)
   26      {
   27          cout &lt;&lt; X.what() &lt;&lt; endl;
   28      }     
   29      
   30   
   31   
   32   }
   33   
</pre>
<hr>
</body>
</html>





















⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -