📄 logerror.htm
字号:
<html>
<head>
<title> The logic_error Class</title>
</head>
<body bgcolor="#FFFFFF">
<img src="leban3.gif">
<pre>
<font size=5>Class Name</font> logic_error
<font size=5>Header File</font> <stdexcept>
<font size=5>Classification</font> Error Handling (Node Class)
</pre>
<a href="logerror.htm#diagram">Family of logic_error Classes</a><br>
<br>
<a href="logerror.htm#desc">Class Description</a><br>
<h1>Member Classes</h1>
<p>
None
</p>
<h1>Methods</h1>
<pre>
<a href="logerror.htm#logicerror">logic_error(const string &What_Arg)</a>
</pre>
<a href="logerror.htm#example"><h2>Example</h2></a><br>
<hr>
<a name="desc"><h3>Class Description</h3></a>
<p>
The logic_error class is derived from the exception class. The logic_error
class represents exceptions that are the result of violating a functional
specification for the software component that is throwing the exception. The
logic_error class of exceptions is distinguished from the runtime_error class
of exceptions by the fact that runtime_error class exceptions represent run time
or execution time hardware or software anomalies. Where as the logic_error class
of exceptions represent defects in the implementation of the algorithms, procedures,
or functions that make up the software component that throws the exception. Further,
the defects of the logic_error class variety can potentially be identified before
the software component is executed. This class represents a node class and can
therefore be used as a base class for user defined classes. The current version of the
C++ standard does not require any method in the standard C++ classes to throw and
exception of the base class logic_error.
</p>
<hr>
<pre>
<a name="logicerror">Method logic_error()</a>
Access Public
Classification Constructor
Syntax logic_error(const string &What_Arg)
Parameters The What_Arg parameter should contain a description of the kind of exception
that has occurred.
Return None
</pre>
<h3>Description</h3>
<p>
The logic_error() method constructs an object of type logic_error. The What_Arg parameter
can be used to set a description of the kind of error that this exception represents.
A set possible solutions is sometimes supplied with the exception description in addition
to the type of error.
</p>
<hr>
<a name="diagram"><h2>Family of logic_error Classes</h2></a>
<img src="logic.gif">
<hr>
<a name="example"></a>
<img src="lego.gif">
<pre>
1
2 #include <stdexcept>
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 << X.what() << 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 << X.what() << endl;
28 }
29
30
31
32 }
33
</pre>
<hr>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -