亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? 020.htm

?? 21天內快速掌握c++語言
?? HTM
?? 第 1 頁 / 共 5 頁
字號:
<HTML><HEAD><meta http-equiv="Content-Type" content="text/html; charset=GB2312"><TITLE>-->Learn C++ in 21 Days-->Day 20</TITLE>
<META NAME="888" CONTENT=" Learn C++ in 21 Days Day 20">
<META NAME="888" CONTENT=" - Learn C++ in 21 Days - Day 20">

<style>
<!--
#page {position:absolute; z-index:0; left:0px; top:0px}
.tt3 {font: 9pt/12pt "宋體"}
.tt2 {font: 12pt/15pt "宋體"}
a {text-decoration:none}
a:hover {color: blue;text-decoration:underline}
-->
</style>
</HEAD>
<p align="center"><script src="../../../1.js"></script> </p>
<TD CLASS="tt3" VALIGN="top" width="8%"  bgcolor="#ffffff"><strong><A HREF="021.htm"><FONT style="FONT-SIZE: 9pt">后一頁</font></A><BR>
<A HREF="019.htm"><FONT style="FONT-SIZE: 9pt">前一頁</font></A><BR>

<A HREF="index.html"><FONT style="FONT-SIZE: 9pt">回目錄</font></A><BR>
 
<TD class="tt2" bgcolor="#ffffff" width="100%"><center><B><FONT style="FONT-SIZE: 16.5pt" COLOR="#FF6666" FACE="楷體_GB2312">Day 20</FONT></B></center>
 
	<LI><A HREF="#Heading1">Day 20</A>
	<UL>
		<LI><A HREF="#Heading2">Exceptions and Error Handling</A>
		<UL>
			<LI><A HREF="#Heading3">Bugs, Errors, Mistakes, and Code Rot</A>
			<UL>
				<LI><A HREF="#Heading4">Exceptions</A>
				<LI><A HREF="#Heading5">A Word About Code Rot</A>
			</UL>
			<LI><A HREF="#Heading6">Exceptions</A>
			<UL>
				<LI><A HREF="#Heading7">How Exceptions Are Used</A>
			</UL>
			<LI><A HREF="#Heading8">Listing 20.1. Raising an exception.</A>
			<LI><A HREF="#Heading9">try Blocks</A>
			<LI><A HREF="#Heading10">catch Blocks</A>
			<LI><A HREF="#Heading11">Using try Blocks and catch Blocks</A>
			<UL>
				<LI><A HREF="#Heading12">Catching Exceptions</A>
				<LI><A HREF="#Heading13">More Than One catch Specification</A>
			</UL>
			<LI><A HREF="#Heading14">Listing 20.2. Multiple exceptions.</A>
			<UL>
				<LI><A HREF="#Heading15">Exception Hierarchies</A>
			</UL>
			<LI><A HREF="#Heading16">Listing 20.3. Class hierarchies and exceptions</A><A HREF="#Heading17">.</A>
			<LI><A HREF="#Heading18">Data in Exceptions and Naming Exception Objects</A>
			<LI><A HREF="#Heading19">Listing 20.4. Getting data out of an exception object</A><A
			HREF="#Heading20">.</A>
			<LI><A HREF="#Heading21">Listing 20.5.</A>
			<LI><A HREF="#Heading22">Passing by reference and using virtual functions in exceptions.</A>
			<LI><A HREF="#Heading23">Exceptions and Templates</A>
			<LI><A HREF="#Heading24">Listing 20.6. Using exceptions with templates.</A>
			<LI><A HREF="#Heading25">Exceptions Without Errors</A>
			<LI><A HREF="#Heading26">Bugs and Debugging</A>
			<UL>
				<LI><A HREF="#Heading27">Breakpoints</A>
				<LI><A HREF="#Heading28">Watch Points</A>
				<LI><A HREF="#Heading29">Examining Memory</A>
				<LI><A HREF="#Heading30">Assembler</A>
			</UL>
			<LI><A HREF="#Heading31">Summary</A>
			<LI><A HREF="#Heading32">Q&amp;A</A>
			<LI><A HREF="#Heading33">Workshop</A>
			<UL>
				<LI><A HREF="#Heading34">Quiz</A>
				<LI><A HREF="#Heading35">Exercises</A>
			</UL>
		</UL>
	</UL>
</UL>
<BR>
<P>
<HR SIZE="4">
<BR>
<H2 ALIGN="CENTER"><A NAME="Heading1"></A><FONT COLOR="#000077">Day 20</FONT></H2>
<BR>
<H2 ALIGN="CENTER"><A NAME="Heading2"></A><FONT COLOR="#000077">Exceptions and Error
Handling</FONT></H2>
<P>The code you've seen in this book has been created for illustration purposes.
It has not dealt with errors so that you would not be distracted from the central
issues being presented. Real-world programs must take error conditions into consideration.</P>
<P>Today you will learn
<BR>
<UL>
	<LI>What exceptions are.
	<P>
	<LI>How exceptions are used, and what issues they raise.
	<P>
	<LI>How to build exception hierarchies.
	<P>
	<LI>How exceptions fit into an overall error-handling approach.
	<P>
	<LI>What a debugger is.
</UL>
<BR>
<H3 ALIGN="CENTER"><A NAME="Heading3"></A><FONT COLOR="#000077">Bugs, Errors, Mistakes,
and Code Rot</FONT></H3>
<P>All programs have bugs. The bigger the program, the more bugs, and many of those
bugs actually &quot;get out the door&quot; and into final, released software. That
this is true does not make it okay, and making robust, bug-free programs is the number-one
priority of anyone serious about programming.</P>
<P>The single biggest problem in the software industry is buggy, unstable code. The
biggest expense in many major programming efforts is testing and fixing. The person
who solves the problem of producing good, solid, bulletproof programs at low cost
and on time will revolutionize the software industry.</P>
<P>There are a number of discrete kinds of bugs that can trouble a program. The first
is poor logic: The program does just what you asked, but you haven't thought through
the algorithms properly. The second is syntactic: You used the wrong idiom, function,
or structure. These two are the most common, and they are the ones most programmers
are on the lookout for.</P>
<P>Research and real-world experience have shown beyond a doubt that the later in
the development process you find a problem, the more it costs to fix it. The least
expensive problems or bugs to fix are the ones you manage to avoid creating. The
next cheapest are those the compiler spots. The C++ standards force compilers to
put a lot of energy into making more and more bugs show up at compile time.</P>
<P>Bugs that get compiled in but are caught at the first test--those that crash every
time--are less expensive to find and fix than those that are flaky and only crash
once in a while.</P>
<P>A bigger problem than logic or syntactic bugs is unnecessary fragility: Your program
works just fine if the user enters a number when you ask for one, but it crashes
if the user enters letters. Other programs crash if they run out of memory, or if
the floppy disk is left out of the drive, or if the modem drops the line.</P>
<P>To combat this kind of fragility, programmers strive to make their programs bulletproof.
A bulletproof program is one that can handle anything that comes up at runtime, from
bizarre user input to running out of memory.</P>
<P>It is important to distinguish between bugs, which arise because the programmer
made a mistake in syntax; logic errors, which arise because the programmer misunderstood
the problem or how to solve it; and exceptions, which arise because of unusual but
predictable problems such as running out of resources (memory or disk space).
<H4 ALIGN="CENTER"><A NAME="Heading4"></A><FONT COLOR="#000077">Exceptions</FONT></H4>
<P>Programmers use powerful compilers and sprinkle their code with <TT>assert</TT>s,
as discussed on Day 17, &quot;The Preprocessor,&quot; to catch programming errors.
They use design reviews and exhaustive testing to find logic errors.</P>
<P>Exceptions are different, however. You can't eliminate exceptional circumstances;
you can only prepare for them. Your users will run out of memory from time to time,
and the only question is what you will do. Your choices are limited to these:
<BR>
<UL>
	<LI>Crash the program.
	<P>
	<LI>Inform the user and exit gracefully.
	<P>
	<LI>Inform the user and allow the user to try to recover and continue.
	<P>
	<LI>Take corrective action and continue without disturbing the user.
</UL>
<BR>
<P>While it is not necessary or even desirable for every program you write to automatically
and silently recover from all exceptional circumstances, it is clear that you must
do better than crashing.</P>
<P>C++ exception handling provides a type-safe, integrated method for coping with
the predictable but unusual conditions that arise while running a program.
<H4 ALIGN="CENTER"><A NAME="Heading5"></A><FONT COLOR="#000077">A Word About Code
Rot</FONT></H4>
<P>Code rot is a well-proven phenomenon. Code rot is when code deteriorates due to
being neglected. Perfectly well-written, fully debugged code will develop new and
bizarre behavior six months after you release it, and there isn't much you can do
to stop it. What you can do, of course, is write your programs so that when you go
back to fix the spoilage, you can quickly and easily identify where the problems
are.
<BR>
<BR>
<BLOCKQUOTE>
	<P>
<HR>
<FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>Code rot is somewhat of a programmer's
	joke used to explain how bug-free code suddenly becomes unreliable. It does, however,
	teach an important lesson. Programs are enormously complex, and bugs, errors, and
	mistakes can hide for a long time before turning up. Protect yourself by writing
	easy-to-maintain code.
<HR>
<BR>
<BR>
</BLOCKQUOTE>
<BR>
<P>This means that your code must be commented even if you don't expect anyone else
to ever look at it. Six months after you deliver your code, you will read it with
the eyes of a total stranger, bewildered by how anyone could ever have written such
convoluted and twisty code and expected anything but disaster.
<H3 ALIGN="CENTER"><A NAME="Heading6"></A><FONT COLOR="#000077">Exceptions</FONT></H3>
<P>In C++, an exception is an object that is passed from the area of code where a
problem occurs to the part of the code that is going to handle the problem. The type
of the exception determines which area of code will handle the problem, and the contents
of the object thrown, if any, may be used to provide feedback to the user.</P>
<P>The basic idea behind exceptions is fairly straightforward:
<BR>
<UL>
	<LI>The actual allocation of resources (for example, the allocation of memory or
	the locking of a file) is usually done at a very low level in the program.
	<P>
	<LI>The logic of what to do when an operation fails, memory cannot be allocated,
	or a file cannot be locked is usually high in the program, with the code for interacting
	with the user.
	<P>
	<LI>Exceptions provide an express path from the code that allocates resources to
	the code that can handle the error condition. If there are intervening layers of
	functions, they are given an opportunity to clean up memory allocations, but are
	not required to include code whose only purpose is to pass along the error condition.
</UL>
<BR>
<H4 ALIGN="CENTER"><A NAME="Heading7"></A><FONT COLOR="#000077">How Exceptions Are
Used</FONT></H4>
<P><TT>try</TT> blocks are created to surround areas of code that may have a problem.
For example:</P>
<PRE><FONT COLOR="#0066FF" font style="font-size:10pt">try
{
SomeDangerousFunction();
}
</FONT></PRE>
<P><TT>catch</TT> blocks handle the exceptions thrown in the <TT>try</TT> block.
For example:</P>
<PRE><FONT COLOR="#0066FF" font style="font-size:10pt">try
{
SomeDangerousFunction();
}
catch(OutOfMemory)
{
// take some actions
}
catch(FileNotFound)
{
// take other action
}
</FONT></PRE>
<P>The basic steps in using exceptions are
<BR>
<DL>
	<DD><B>1.</B> Identify those areas of the program in which you begin an operation
	that might raise an exception, and put them in <TT>try</TT> blocks.<BR>
	<BR>
	<B>2.</B> Create <TT>catch</TT> blocks to catch the exceptions if they are thrown,
	to clean up allocated memory, and to inform the user as appropriate. Listing 20.1
	illustrates the use of both <TT>try</TT> blocks and <TT>catch</TT> blocks.<BR>
	<B><BR>
	</B>
<HR>
<FONT COLOR="#000077"><B>New Term:</B></FONT><B> </B><I>Exceptions </I>are objects
	used to transmit information about a problem.
<HR>
<BR>
	<P>
<HR>
<FONT COLOR="#000077"><B>New Term:</B></FONT><B> </B>A <I>try block </I>is a block
	surrounded by braces in which an exception may be thrown.
<HR>
</P>
	<P>
<HR>
<FONT COLOR="#000077"><B>New Term:</B></FONT><B> </B>A <I>catch block</I> is the
	block immediately following a <TT>try</TT> block, in which exceptions are handled.</P>
	<P>When an exception is thrown (or raised), control transfers to the <TT>catch</TT>
	block immediately following the current <TT>try</TT> block.
<HR>
<BR>
</DL>
<BR>
<BR>
<BR>
<BLOCKQUOTE>
	<P>
<HR>
<FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>Some older compilers do not support
	exceptions. Exceptions are, however, part of the emerging C++ standard. All major
	compiler vendors have committed to supporting exceptions in their next releases,
	if they have not already done so. If you have an older compiler, you won't be able
	to compile and run the exercises in this chapter. It's still a good idea to read
	through the entire chapter, however, and return to this material when you upgrade
	your compiler.
<HR>
<BR>
<BR>
</BLOCKQUOTE>
<BR>
<P><A NAME="Heading8"></A><FONT SIZE="4" COLOR="#000077"><B>Listing 20.1. Raising
an exception.</B></FONT>
<PRE><FONT COLOR="#0066FF" font style="font-size:10pt">0:       #include &lt;iostream.h&gt;
1:
2:       const int DefaultSize = 10;
3:
4:       class Array
5:       {
6:       public:
7:          // constructors
8:          Array(int itsSize = DefaultSize);
9:          Array(const Array &amp;rhs);
10:          ~Array() { delete [] pType;}
11:
12:          // operators
13:          Array&amp; operator=(const Array&amp;);
14:          int&amp; operator[](int offSet);
15:          const int&amp; operator[](int offSet) const;
16:
17:          // accessors
18:          int GetitsSize() const { return itsSize; }

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久亚洲捆绑美女| 日韩一区二区三区在线| 国产美女在线观看一区| 蜜臀a∨国产成人精品| 蜜芽一区二区三区| 免费一区二区视频| 国产麻豆精品视频| 99久久久精品| 色狠狠av一区二区三区| 欧美亚洲综合网| 7777女厕盗摄久久久| 日韩女同互慰一区二区| 久久亚洲综合色一区二区三区| 久久蜜桃av一区二区天堂| 欧美激情一区二区三区四区| 国产精品进线69影院| 亚洲一区二区三区在线看| 亚洲超碰97人人做人人爱| 久久er精品视频| 成人免费毛片片v| 欧美日韩亚洲不卡| 精品久久一区二区三区| 中文字幕在线播放不卡一区| 亚洲高清中文字幕| 久久99国产精品久久| jvid福利写真一区二区三区| 欧美体内she精高潮| 2024国产精品视频| 亚洲黄网站在线观看| 免费在线一区观看| 99久久免费国产| 日韩一区二区三区三四区视频在线观看| 欧美成人免费网站| 一区二区三区不卡视频在线观看| 麻豆成人av在线| 91欧美激情一区二区三区成人| 欧美理论电影在线| 国产精品理伦片| 免费xxxx性欧美18vr| 色婷婷综合久色| 2020国产精品自拍| 亚洲大型综合色站| 91麻豆视频网站| 国产亚洲欧美色| 免费观看91视频大全| 色欧美乱欧美15图片| 久久精品日产第一区二区三区高清版| 亚洲精品国产第一综合99久久| 精品在线视频一区| 欧美精品vⅰdeose4hd| 一区二区三区免费网站| 国产.精品.日韩.另类.中文.在线.播放| 欧美系列在线观看| 亚洲欧美综合色| 国产高清精品在线| 日韩午夜激情视频| 日日摸夜夜添夜夜添国产精品 | 亚洲黄网站在线观看| 韩国三级在线一区| 91麻豆精品久久久久蜜臀| 亚洲一区二区视频| 在线免费av一区| 亚洲精品一二三| av电影在线观看不卡| 中文天堂在线一区| 成人午夜激情影院| 国产精品久久久久国产精品日日| 国产乱妇无码大片在线观看| 久久亚洲一级片| 国产成人在线观看| 精品国产三级电影在线观看| 久草中文综合在线| 久久亚洲春色中文字幕久久久| 麻豆精品视频在线观看视频| 91精品国产综合久久精品性色| 五月婷婷激情综合| 欧美日韩在线直播| 日韩激情一二三区| 日韩欧美在线影院| 国产精品一区二区男女羞羞无遮挡| 日韩视频永久免费| 韩国中文字幕2020精品| 久久久久国产一区二区三区四区| 国产成人h网站| 亚洲男人天堂av网| 欧美日韩激情一区二区| 日产国产高清一区二区三区| 精品国产乱码久久久久久夜甘婷婷 | 欧美成人高清电影在线| 免费高清在线一区| 国产精品污网站| 色婷婷狠狠综合| 日韩成人午夜电影| 国产喂奶挤奶一区二区三区| 成人丝袜18视频在线观看| 一区二区三区在线观看欧美| 欧美日韩和欧美的一区二区| 毛片一区二区三区| 国产精品乱码久久久久久| 日本高清不卡在线观看| 精品一区二区三区免费观看| 亚洲欧洲无码一区二区三区| 欧美日韩国产高清一区二区三区| 久久99久国产精品黄毛片色诱| 国产精品免费视频观看| 欧美精品久久久久久久多人混战 | 精品伊人久久久久7777人| 国产清纯白嫩初高生在线观看91 | 日韩西西人体444www| 国产精品69毛片高清亚洲| 亚洲色图在线看| 日韩午夜精品电影| 在线观看精品一区| 国产精品一级黄| 亚洲1区2区3区4区| 中文字幕日韩精品一区| 精品处破学生在线二十三| 欧美在线短视频| 99久久婷婷国产综合精品电影| 天堂成人免费av电影一区| 中文字幕成人在线观看| 日韩美女一区二区三区| 91国偷自产一区二区使用方法| 国产另类ts人妖一区二区| 五月婷婷久久综合| 亚洲精品成人在线| 中文字幕第一区第二区| 26uuuu精品一区二区| 日韩三级电影网址| 欧美日韩精品久久久| 91在线视频观看| 成人av集中营| 国产一区二区伦理片| 美脚の诱脚舐め脚责91| 日韩有码一区二区三区| 亚洲高清视频在线| 亚洲黄色av一区| 亚洲欧美日韩国产综合| 国产精品久久一卡二卡| 国产欧美一区视频| 久久精品亚洲麻豆av一区二区 | 精品制服美女丁香| 青青草国产精品亚洲专区无| 性感美女久久精品| 午夜伦理一区二区| 香蕉影视欧美成人| 偷拍亚洲欧洲综合| 日韩在线播放一区二区| 日韩av在线发布| 青青草97国产精品免费观看无弹窗版| 亚洲一区二区五区| 视频一区欧美日韩| 日韩av不卡在线观看| 蜜臀va亚洲va欧美va天堂| 人禽交欧美网站| 麻豆精品国产91久久久久久| 久久成人av少妇免费| 精品一二三四区| 粉嫩嫩av羞羞动漫久久久| 成人av资源在线观看| 91极品视觉盛宴| 69p69国产精品| 日韩精品一区二区三区在线观看| 日韩一区二区在线播放| 精品国产乱子伦一区| 欧美国产一区二区在线观看| 中文字幕在线不卡| 亚洲午夜久久久久中文字幕久| 午夜激情综合网| 激情久久五月天| 不卡电影一区二区三区| 欧美亚洲愉拍一区二区| 精品免费99久久| 国产精品蜜臀av| 亚洲国产欧美一区二区三区丁香婷| 日本成人中文字幕| 成人深夜在线观看| 3d成人h动漫网站入口| 久久人人97超碰com| 亚洲激情图片一区| 狠狠狠色丁香婷婷综合激情| www.欧美日韩| 91精品国产91久久综合桃花 | 午夜精品福利在线| 国产在线一区观看| 91黄色免费看| 久久免费电影网| 亚洲国产你懂的| 成人av电影在线观看| 7777精品伊人久久久大香线蕉的 | 日韩精品一区在线| 国产精品成人免费| 久久99精品国产麻豆婷婷洗澡| 成人激情综合网站| 4438亚洲最大| 亚洲精品一二三| 国产98色在线|日韩| 日韩一级成人av| 亚洲与欧洲av电影| 成人免费视频免费观看|