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

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

?? apd.htm

?? 21天學會VC的英文版
?? HTM
?? 第 1 頁 / 共 3 頁
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"><HTML><HEAD>	<META HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=iso-8859-1"><SCRIPT LANGUAGE="JavaScript"><!--function popUp(pPage) { var fullURL = document.location; var textURL = fullURL.toString(); var URLlen = textURL.length; var lenMinusPage = textURL.lastIndexOf("/"); lenMinusPage += 1; var fullPath = textURL.substring(0,lenMinusPage); popUpWin = window.open('','popWin','resizable=yes,scrollbars=no,width=525,height=394'); figDoc= popUpWin.document; zhtm= '<HTML><HEAD><TITLE>' + pPage + '</TITLE>'; zhtm += '</head>'; zhtm += '<BODY bgcolor="#FFFFFF">'; zhtm += '<IMG SRC="' + fullPath + pPage + '">'; zhtm += '<P><B>' + pPage + '</B>'; zhtm += '</BODY></HTML>'; window.popUpWin.document.write(zhtm); window.popUpWin.document.close(); // Johnny Jackson 4/28/98 }//-->                                                                </SCRIPT><link rel="stylesheet" href="/includes/stylesheets/ebooks.css">	<META NAME="GENERATOR" Content="Symantec Visual Page Mac 1.1.1">	<TITLE>Teach Yourself Visual C++ 6 in 21 Days -- Appendix D -- Understanding and Exception Handling</TITLE></HEAD><BODY TEXT="#000000" BGCOLOR="#FFFFFF"><H1 ALIGN="CENTER"><IMG SRC="../button/sams.gif" WIDTH="171" HEIGHT="66" ALIGN="BOTTOM"BORDER="0"><BR>Teach Yourself Visual C++ 6 in 21 Days</H1><CENTER><P><A HREF="../apc/apc.htm"><IMG SRC="../button/previous.gif" WIDTH="128" HEIGHT="28"ALIGN="BOTTOM" ALT="Previous chapter" BORDER="0"></A><A HREF="../ape/ape.htm"><IMGSRC="../button/next.gif" WIDTH="128" HEIGHT="28" ALIGN="BOTTOM" ALT="Next chapter"BORDER="0"></A><A HREF="../index.htm"><IMG SRC="../button/contents.gif" WIDTH="128"HEIGHT="28" ALIGN="BOTTOM" ALT="Contents" BORDER="0"></A> <HR></CENTER><H1 ALIGN="CENTER">- D -<BR>Understanding and Exception Handling</H1><H1></H1><UL>	<LI><A HREF="#Heading1">Using Exceptions</A>	<UL>		<LI><A HREF="#Heading2">Running Code and Catching the Errors</A>		<LI><A HREF="#Heading3">Throwing Exceptions</A>		<LI><A HREF="#Heading4">Deleting Exceptions</A>	</UL>	<LI><A HREF="#Heading5">MFC Exception Types</A>	<UL>		<LI><A HREF="#Heading6">Using the CException Base Class</A>		<LI><A HREF="#Heading7">Using the Memory Exception</A>		<LI><A HREF="#Heading8">Using the Resource Exceptions</A>		<LI><A HREF="#Heading9">Using the File and Archive Exceptions</A>		<LI><A HREF="#Heading10">Using the Database Exceptions</A>		<LI><A HREF="#Heading11">Using OLE Exceptions</A>		<LI><A HREF="#Heading12">Using the Not Supported Exception</A>		<LI><A HREF="#Heading13">Using the User Exception</A>		<LI><A HREF="#Heading14">Generating Your Own Custom Exception Classes</A>	</UL></UL><P><HR SIZE="4"><BR><I>by Jon Bates</I></P><P><I></I><H2><A NAME="Heading1"></A>Using Exceptions</H2><P>An <I>exception</I> is an object that holds details about something that has gonewrong. The clever thing about exception handling is that you can create an exceptionwhen something goes wrong in a low-level function and have it automatically bubbleback up to a calling function that can deal with all such exceptions in one place.</P><P><H3><A NAME="Heading2"></A>Running Code and Catching the Errors</H3><P>The system automatically detects certain error conditions and generates exceptionsfor them. If you don't deal with them in your application, they will bubble backout of your code and be handled by Windows's own exception-catching mechanisms. Ifyou want to see this in action, just add the following two lines to any of your codeand run it:</P><P><PRE>CDC* pNullDC = 0;pNullDC-&gt;SetPixel(0,0,0);</PRE><P>The first line declares a device context pointer pNullDC and sets it to pointthe memory address to zero (which isn't a good place for any object to be). Obviouslythere isn't a valid object at this address, so when the following SetPixel() functionis called, the system tries to find the object at address zero. The memory managementhardware and software know that the program has no right being at this memory addressand raise a memory access violation exception.</P><P>If you run these lines of code from outside the Visual C++ debugger, you'll seea dialog box familiar to all Windows users, as shown in Figure D.1.</P><P><A HREF="javascript:popUp('29fig01.gif')"><B>FIGURE D.1.</B></A><B> </B><I>TheWindows memory access violation Exception dialog box.</I></P><P>However, if you run the application from the Visual C++ debugger, the debuggerfirst catches the exception for you and displays the Developer Studio dialog boxinstead, as shown in Figure D.2.</P><P><A HREF="javascript:popUp('29fig02.gif')"><B>FIGURE D.2.</B></A><B> </B><I>TheDeveloper Studio-handled memory access violation exception.</I></P><P>Memory access violations are very severe exceptions that will crash your programwithout any chance to catch them. There are many less severe exceptions, such asthe file-handling exception CFileException. This exception is thrown when erroneousfile operations occur, such as attempting to seek to the beginning of an unopenedfile:</P><P><PRE>CFile fileNotOpen;fileNotOpen.SeekToBegin();</PRE><P>This results in a system-generated dialog box (see Figure D.3). If you click OK,your program will continue as usual.</P><P><A HREF="javascript:popUp('29fig03.gif')"><B>FIGURE D.3.</B></A><B> </B><I>TheWindows default dialog box for a file exception.</I></P><P>Rather than letting the system catch the exception, you can catch the exceptionand deal with it yourself in a more graceful manner. To do this, you must use theC++ try and catch keywords. You can use these by defining a block of code to try;then, when a specified exception is raised, an action is defined in the catch block(see Listing D.1).</P><P><H4>LISTING D.1.&nbsp;LST29_1.CPP--USING A try AND catch BLOCK TO CATCH CFileExceptions.</H4><PRE>1: // ** Try a block of code2: try3: {4:     CFile fileNotOpen;5:     fileNotOpen.SeekToBegin();6: }7: catch(CFileException* e)    // Catch File Exceptions8: {9:     // ** Check the cause of the exception10:     if (e-&gt;m_cause == CFileException::fileNotFound)11:        AfxMessageBox(&quot;Oops, forgot to open the file!&quot;);12:     e-&gt;Delete();13: } </PRE><P>In Listing D.1, a try block is defined around the file operations at lines 4 and5. If these lines don't raise an exception, the code will continue as normal. However,if a CFileException is raised, it will be caught by the catch keyword in line 7,and the variable e will point to the new exception. The CFileException object hasan m_cause code that defines exactly why the exception was raised. This is checkedon line 10, and if this was a CFileException::fileNotFound code, the message boxon line 11 is displayed.</P><P>Notice that the Delete() member function of the CException class (the base classof CFileException) in line 12 will delete the exception for you. You must ensurethat exceptions are always deleted when you are finished with them.</P><P>The try block can include calls to other functions and could be used to catchany specified exceptions raised in a large portion of the application, as shown inListing D.2.</P><P><H4>LISTING D.2.&nbsp;LST29_2.CPP--A try BLOCK CAN INCLUDE MANY FUNCTION CALLS ANDCALLS FROM THOSE FUNCTIONS.</H4><PRE>1: try2: {3:     // ... Lots of code4:     DoLotsOfFileHandling();5:     // ... More code6:     EvenMoreFileHandling();7:     // ... And more Code8: }9: catch(CFileException* e)    // Catch File Exceptions10: {11:     // ** Check the cause of the exception12:     if (e-&gt;m_cause == CFileException::fileNotFound)13:        AfxMessageBox(&quot;Oops, forgot to open the file!&quot;);14:     e-&gt;Delete();15: }</PRE><P>In Listing D.2 the DoLotsOfFileHandling() function on line 4 could implement somefile handling itself, as well as calls to other functions, as with EvenMoreFileHandling()on line 6. Should a file exception arise through any of these file operations, theexception will bubble back so that the same catch block will be executed in lines9 through 13 with e pointing to the CFileException object. Finally the exceptionis deleted in line 14.</P><P>If you want to catch two different exceptions from the try block, you can addcatch blocks to handle each different exception, as shown in Listing D.3.</P><P><H4>LISTING D.3.&nbsp;LST29_3.CPP--HANDLING TWO DIFFERENT EXCEPTIONS WITH THE EXCEPTION-SPECIFIC catch BLOCKS.</H4><PRE>1: try2: {3:     // ** This file operation is ok4:     CMemFile fileMemFile;5:     fileMemFile.SeekToBegin();6: 7:     // ** But you can't have two different system 8:     // ** resources with the same name.9:     CMutex        mutex1(0,&quot;Same Name&quot;);10:     CSemaphore    semaphore1(1,1,&quot;Same Name&quot;);11: }12: catch(CFileException* e)    // Catch File Exceptions13: {14:     if (e-&gt;m_cause == CFileException::fileNotFound)15:        AfxMessageBox(&quot;Oops, forgot to open the file!&quot;);16:     e-&gt;Delete();17: }18: catch(CResourceException* e)     &Acirc;// Catch Resource Exceptions19: {20:     // ** Report the Resource exception error21:     AfxMessageBox(&quot;Oops, duplicate resource name&quot;);22:     e-&gt;Delete();23: } </PRE><P>In Listing D.3, the memory file is automatically created in line 4, so line 5won't cause a file exception. However, naming two different system resources (a mutexand a semaphore) with the same name does cause a CResourceException in line 10 thatis then caught by the second catch block in line 18, which displays the message boxin line 21. If you try this code yourself, remember to add an #include &lt;afxmt.h&gt;line for the CMutex and CSemaphore definitions.</P><P>If you want to do a blanket exception catch, you don't need to have a catch blockfor each type of exception; instead, you can catch the CException base class exceptionfrom which all the other more specific exception classes are derived (see ListingD.4).</P><P><H4>LISTING D.4.&nbsp;LST29_4.CPP--USING THE catch BLOCK TO CATCH ALL TYPES OF EXCEPTIONS.</H4><PRE>1: // ** Try a block of code2: try3: {4:     // ** Lots of code ...5: }6: catch(CException* e)7: {8:     // ** General Error message, details in e9:     AfxMessageBox(&quot;Oops, something went wrong!&quot;);10:     e-&gt;Delete();11: }</PRE><P>Notice that on line 6 the CException base class is used rather than a specificexception such as CFileException or CResourceException. You can test which type ofexception was raised using the IsKindOf() function inside the catch block. For example,to test whether a file exception has been raised, you might use the following lines:</P><P><PRE>if (e-&gt;IsKindOf(RUNTIME_CLASS(CFileException)))AfxMessageBox(&quot;File Exception&quot;);</PRE><P>Because exceptions are derived from CObject, they support the MFC runtime classinformation<I>.</I> By using DECLARE_DYNAMIC and IMPLEMENT_DYNAMIC, the class informationis bundled into the derived exception object so that the IsKindOf() function canbe used to check for a specific class type. The RUNTIME_CLASS macro turns class namesinto a pointer to a CRuntimeClass object for the specified object. The IsKindOf()member function will then return TRUE if the object being called is of that runtimeclass.</P><P>The &quot;MFC Exception Types&quot; section later in this chapter covers how youcan determine exception-specific information from each type of MFC exception caughtin a catch block.</P><BLOCKQUOTE>	<P><HR>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美午夜精品免费| 国产精品一区三区| 色综合久久综合网97色综合| 久久一区二区三区国产精品| 亚洲黄网站在线观看| 99re在线精品| 亚洲婷婷在线视频| 色天使久久综合网天天| 国产情人综合久久777777| 国产一区二区三区免费看| 精品日韩一区二区| 激情成人综合网| 精品sm在线观看| 成人午夜视频福利| 国产精品久久久久毛片软件| 久草在线在线精品观看| 欧美精品一区二区三区在线| 国产精品一区二区三区乱码| 精品国产一区二区在线观看| 激情小说欧美图片| 国产欧美日韩不卡免费| 91在线小视频| 亚洲一级二级三级在线免费观看| 91色九色蝌蚪| 亚洲成人av一区二区| 欧美一区二区三区视频在线| 久草热8精品视频在线观看| 国产色综合久久| 91美女片黄在线| 亚洲国产美国国产综合一区二区| 欧美精品在线视频| 韩国欧美一区二区| 国产精品久久久久久福利一牛影视| 91在线丨porny丨国产| 日韩制服丝袜av| 国产午夜久久久久| 色狠狠色噜噜噜综合网| 奇米888四色在线精品| 国产欧美精品日韩区二区麻豆天美| 色av成人天堂桃色av| 日本系列欧美系列| 成人欧美一区二区三区1314| 欧美日韩国产综合一区二区 | 国产视频不卡一区| 欧美亚洲动漫精品| 国产一区二区三区在线观看精品| 亚洲视频一区在线| 91精品福利在线一区二区三区| 国产一区二区美女| 一级做a爱片久久| 精品成人在线观看| 欧美丝袜丝交足nylons| 国产精品91xxx| 日韩精品一二区| 亚洲视频免费观看| 久久网站最新地址| 色综合久久综合| 国产精品一线二线三线精华| 亚洲综合激情网| 国产欧美日韩综合精品一区二区| 欧美三级电影在线看| 国产成人精品三级麻豆| 亚洲国产精品一区二区www在线| 精品国产一区二区亚洲人成毛片 | 91蜜桃网址入口| 成人一区二区三区在线观看| 国产精品午夜春色av| 欧美日本在线播放| 色噜噜狠狠一区二区三区果冻| 日韩不卡一二三区| 日韩一区欧美二区| 国产麻豆一精品一av一免费| 亚洲成人黄色影院| 视频一区欧美日韩| 日日夜夜精品视频天天综合网| 亚洲午夜私人影院| 亚洲一二三区视频在线观看| 一区二区三区精密机械公司| 一区二区三区在线视频观看58| 一区二区三区四区五区视频在线观看| 中文字幕在线不卡视频| 中文字幕电影一区| 亚洲欧美日韩国产另类专区| 亚洲日穴在线视频| 一区二区三区成人| 日韩精品免费专区| 久久er99精品| 成人黄动漫网站免费app| 成人精品免费看| 99精品视频免费在线观看| 91麻豆免费观看| 欧美网站一区二区| 欧美一区二区大片| 久久精品亚洲乱码伦伦中文| 中文字幕不卡一区| 亚洲成av人片www| 国模娜娜一区二区三区| 国产91高潮流白浆在线麻豆| 99久久综合狠狠综合久久| 成人激情综合网站| 在线观看国产一区二区| 日韩亚洲欧美在线观看| 久久美女艺术照精彩视频福利播放| 日本一区二区久久| 亚洲成人一区二区| 国产一区二三区| 欧美亚州韩日在线看免费版国语版| 在线观看91av| 国产精品网站一区| 亚洲国产毛片aaaaa无费看| 免费精品视频在线| 成人黄色软件下载| 91精品国产免费| 亚洲欧洲日韩在线| 免费高清在线一区| 色综合天天综合网天天看片| 欧美日韩国产精选| 欧美激情一区二区| 婷婷丁香激情综合| 97se狠狠狠综合亚洲狠狠| 欧美一区二区精品| 亚洲精品乱码久久久久久 | 蜜臀av一区二区| 波多野结衣欧美| 精品免费日韩av| 亚洲一二三四在线观看| 国产91精品欧美| 欧美大肚乱孕交hd孕妇| 亚洲免费大片在线观看| 国产一区91精品张津瑜| 91麻豆精品国产自产在线观看一区 | 欧美在线观看你懂的| 精品国产乱码久久久久久牛牛| 亚洲女人的天堂| 成熟亚洲日本毛茸茸凸凹| 91精品国产欧美一区二区成人| 亚洲品质自拍视频| 成人一区二区视频| 久久九九久久九九| 美国十次综合导航| 欧美精品乱人伦久久久久久| 亚洲欧美日韩在线| 国产成人激情av| 欧美精品一区二区三区一线天视频| 亚洲成人av资源| 在线观看精品一区| 亚洲欧美日韩国产综合| 国产乱理伦片在线观看夜一区| 欧美一区二区三区成人| 亚洲国产视频直播| 日本电影亚洲天堂一区| 亚洲国产精品二十页| 国产成人在线视频免费播放| 欧美一区二区视频观看视频| 亚洲成av人片观看| 在线不卡一区二区| 偷拍一区二区三区四区| 欧美日韩欧美一区二区| 午夜欧美在线一二页| 欧美色图激情小说| 午夜精品视频在线观看| 欧美日韩国产精选| 日韩成人午夜电影| 91精品啪在线观看国产60岁| 亚洲1区2区3区4区| 91精品一区二区三区久久久久久 | 在线观看日韩av先锋影音电影院| 亚洲欧洲国产专区| 成人在线综合网站| av综合在线播放| 国内不卡的二区三区中文字幕| 麻豆成人91精品二区三区| 7777精品伊人久久久大香线蕉| 亚洲成年人网站在线观看| 欧美亚洲国产bt| 色噜噜偷拍精品综合在线| 亚洲高清不卡在线观看| 7799精品视频| 国产在线麻豆精品观看| 久久久精品国产免费观看同学| 国产成人精品综合在线观看| 国产精品国产三级国产普通话99 | 日韩理论电影院| 色婷婷精品大视频在线蜜桃视频 | 国产欧美日韩精品a在线观看| 国产99久久久久久免费看农村| 亚洲国产精品v| 欧美在线观看18| 日韩不卡在线观看日韩不卡视频| 日韩三级在线观看| 不卡一区二区在线| 亚洲成国产人片在线观看| 欧美一区二区三区爱爱| 国产福利不卡视频| 亚洲一区自拍偷拍| 久久综合九色综合欧美就去吻| av在线综合网| 美国毛片一区二区三区| 中文字幕乱码亚洲精品一区| 91激情五月电影|