📄 xt9.htm
字号:
<DIV id=Layer2
style="Z-INDEX: 2; LEFT: 512px; VISIBILITY: hidden; WIDTH: 70px; POSITION: absolute; TOP: 190px; HEIGHT: 64px">
<TABLE cellSpacing=0 cellPadding=0 width=70 border=0>
<TBODY>
<TR>
<TD><A href="http://www.nuist.edu.cn/JSJ/syjx/sy.htm"><IMG height=32
src="xt9.files/sy1.gif" width=70 border=0></A></TD></TR>
<TR>
<TD><A href="http://www.nuist.edu.cn/JSJ/syjx/sjdg.htm"><IMG height=32
src="xt9.files/sy2.gif" width=70 border=0></A></TD></TR></TBODY></TABLE></DIV>
<TABLE cellSpacing=0 cellPadding=0 width=777 border=0><!--DWLayoutTable-->
<TBODY>
<TR>
<TD vAlign=top colSpan=3 height=148><IMG height=148
src="xt9.files/maintop.gif" width=777></TD></TR>
<TR>
<TD vAlign=top colSpan=3 height=32><IMG height=32
src="xt9.files/hard_03.gif" width=778 useMap=#Map border=0> </TD></TR>
<TR>
<TD vAlign=top width=181 height=164>
<TABLE cellSpacing=0 cellPadding=0 width="100%" align=right border=0><!--DWLayoutTable-->
<TBODY>
<TR>
<TD vAlign=top colSpan=2 height=30><IMG height=30
src="xt9.files/gai_02.gif" width=177></TD></TR>
<TR>
<TD width=41 height=4></TD>
<TD width=134></TD></TR>
<TR>
<TD height=26>
<DIV align=right><IMG height=15 src="xt9.files/article_common.gif"
width=9></DIV></TD>
<TD>
<DIV align=left><A class=mb14
href="http://www.nuist.edu.cn/JSJ/syjx/sbcl.htm"> 申报材料</A></DIV></TD></TR>
<TR>
<TD height=26>
<DIV align=right><IMG height=15 src="xt9.files/article_common.gif"
width=9></DIV></TD>
<TD>
<DIV align=left><A class=mb14
href="http://www.nuist.edu.cn/JSJ/syjx/szll.htm"> 师资力量</A></DIV></TD></TR>
<TR>
<TD height=26>
<DIV align=right><IMG height=15 src="xt9.files/article_common.gif"
width=9></DIV></TD>
<TD>
<DIV align=center>
<P align=left><A class=mb14
href="http://www.nuist.edu.cn/JSJ/syjx/jxcg.htm"> 教学成果</A></P></DIV></TD></TR>
<TR>
<TD height=26>
<DIV align=right><IMG height=15 src="xt9.files/article_common.gif"
width=9></DIV></TD>
<TD>
<DIV align=left><A
href="http://www.nuist.edu.cn/JSJ/syjx/jxkh.htm"> 教学考核</A></DIV></TD></TR>
<TR>
<TD height=26>
<DIV align=right><IMG height=15 src="xt9.files/article_common.gif"
width=9></DIV></TD>
<TD>
<DIV align=left><A class=mb14
href="http://www.nuist.edu.cn/JSJ/syjx/zwpj.htm"> 自我评价</A></DIV></TD></TR>
<TR>
<TD height=26>
<DIV align=right><IMG height=15 src="xt9.files/article_common.gif"
width=9></DIV></TD>
<TD>
<DIV align=left><A class=mb14
href="http://www.nuist.edu.cn/JSJ/syjx/jsgh.htm"> 建设规划</A></DIV></TD></TR>
<TR>
<TD height=26>
<DIV align=right><IMG height=15 src="xt9.files/article_common.gif"
width=9></DIV></TD>
<TD>
<DIV align=left><A class=mb14
href="http://www.nuist.edu.cn/JSJ/syjx/jcxy.htm"> 教材选用</A></DIV></TD></TR>
<TR>
<TD height=2></TD>
<TD></TD></TR></TBODY></TABLE></TD>
<TD vAlign=top colSpan=2>
<TABLE class=bg height=241 cellSpacing=0 cellPadding=0 width="100%"
border=0>
<TBODY>
<TR>
<TD width="11%" height=33><IMG height=34 src="xt9.files/homedha.gif"
width=55><IMG height=34 src="xt9.files/homedhbg.gif" width=8></TD>
<TD
width="89%"><!-- InstanceBeginEditable name="EditRegion4" --><SPAN
class=s14><STRONG>习题八</STRONG></SPAN><!-- InstanceEndEditable --></TD></TR>
<TR>
<TD colSpan=2><!-- InstanceBeginEditable name="EditRegion5" -->
<TABLE cellSpacing=1 cellPadding=1 width="100%" border=1>
<TBODY>
<TR>
<TD>
<DIV align=center>第9章 C++的异常处理</DIV></TD></TR>
<TR>
<TD>
<P class=xt12>9.1 编写一个“Pastm”异常类型的处理程序,如果[
]运算符在string对象中检测到一个字符-按字典顺序在‘m’之后的小写字母,该异常处理程序就在屏幕上显示一个错误。<BR>#include
<fstream.h><BR>#include <iostream.h><BR>#include
<stdlib.h><BR>void main(int argc, char **
argv)<BR>{<BR> ifstream source(argv[1]); //打开文件<BR> char
line[128];<BR> try{<BR> if(source.fail())<BR> throw
argv[1];<BR> }<BR> catch(char* s)<BR> {<BR> cout
<<"error opening the file "<<s
<<endl;<BR> exit(1);<BR> }<BR> while(!source.eof())<BR> {<BR> source.getline(line,
sizeof(line));<BR> cout <<line
<<endl;<BR> }<BR> source.close();<BR>}</P>
<P class=xt12>9.2 设有下列类声明:<BR>class
A<BR>{<BR> public:<BR> A()<BR> {<BR> n=new
int;<BR> init();<BR> }<BR> private:<BR> int
n;<BR>};<BR>写出init()引发异常的处理程序。<BR>#include
<iostream.h><BR>class A<BR>{<BR> public:<BR> class
Error{};<BR> A()<BR> {<BR> n = new
int;<BR> init();<BR> }<BR> private:<BR> int* n;<BR> void
init()<BR> {<BR> //do something ...<BR> throw
Error();<BR> }<BR>};<BR>void main()<BR>{<BR> try{<BR> A
a;<BR> }<BR> catch(A::Error&)<BR> {<BR> cout
<<"error when
initialize.\n";<BR> }<BR>}<BR></P></TD></TR></TBODY></TABLE><!-- InstanceEndEditable --></TD></TR></TBODY></TABLE></TD></TR>
<TR vAlign=center bgColor=#eeeeee>
<TD colSpan=3 height=28>
<DIV align=center><A
onclick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.nuist.edu.cn')"
href="http://www.nuist.edu.cn/JSJ/syjx/xt/xt9.htm#"><SPAN
class=mb14>设为首页</SPAN></A><STRONG>|</STRONG><A class=mb14
href="javascript:addme()">加入收藏</A><STRONG>|</STRONG><A
href="http://www.nuist.edu.cn/"><SPAN
class=mb14>学校首页</SPAN></A><STRONG>|</STRONG><A
href="http://www.nuist.edu.cn/jsj"><SPAN
class=mb14>计科系首页</SPAN></A></DIV></TD></TR>
<TR>
<TD class=mb14 vAlign=top bgColor=#176bab colSpan=2 height=88>
<DIV align=center><BR><FONT color=#ffffff>Copyright© 2004-2005 Depart of
Computer Science & Technology Nuist</FONT></DIV></TD>
<TD width=15 bgColor=#176bab> </TD></TR>
<TR>
<TD height=1></TD>
<TD width=581></TD>
<TD></TD></TR></TBODY></TABLE><MAP name=Map><AREA shape=RECT coords=9,9,75,25
href="http://www.nuist.edu.cn/JSJ/syjx/index.htm"><AREA shape=RECT
coords=86,9,150,26 href="http://www.nuist.edu.cn/JSJ/syjx/jxdg.htm"><AREA
shape=RECT coords=157,9,220,27
href="http://www.nuist.edu.cn/JSJ/syjx/skja.htm"><AREA shape=RECT
coords=230,9,310,26 href="http://www.nuist.edu.cn/JSJ/syjx/dmt.htm"><AREA
onclick="MM_goToURL('parent','../xt.htm');return document.MM_returnValue"
shape=RECT coords=320,10,397,26
href="http://www.nuist.edu.cn/JSJ/syjx/xt.htm"><AREA
onclick="MM_showHideLayers('Layer1','','hide','Layer2','','show')" shape=RECT
coords=405,10,469,25 href="http://www.nuist.edu.cn/JSJ/syjx/xt/xt9.htm#"><AREA
onclick="MM_showHideLayers('Layer1','','show','Layer2','','hide')" shape=RECT
coords=476,10,538,26 href="http://www.nuist.edu.cn/JSJ/syjx/xt/xt9.htm#"><AREA
shape=RECT coords=549,10,612,26
href="http://www.nuist.edu.cn/JSJ/syjx/ckwx.htm"><AREA shape=RECT
coords=620,9,684,26
href="http://www.nuist.edu.cn/JSJ/syjx/zlxz.htm"></MAP></CENTER><!-- InstanceEnd --></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -