freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

c面向?qū)ο蟪绦蛟O(shè)計(jì)第12章異常處理-在線瀏覽

2025-02-26 00:59本頁面
  

【正文】 main( ) { int m,n。 cinmn。 cout (m/n)endl。 return 1。 } catch語句捕獲一個(gè)整型異常并處理 在 try代碼塊中包含需要監(jiān)控的程序部分 拋出一個(gè)整型異常 C++程序處理異常的一般形式 try{ // try Block } catch (type1 arg){ //exception handling for type1 } catch (type2 arg){ //exception handling for type2 } //... catch (typeN arg){ //exception handling for typeN } try 和 throw 要監(jiān)控的程序部分必須包含在 try代碼塊中,( 在 try塊中調(diào)用的函數(shù)也將被監(jiān)控, 參見 ) 。 try塊中拋出的異常將被緊跟在 try語句之后的catch語句捕獲。 int main( ) { int m,n。 cinmn。 } catch(int) { coutDivided by 0!endl。 } return 0。 return x/y。 ? 在 try語句后面可以有一個(gè)或多個(gè) catch語句。 ? 所有其他的 catch語句都將被忽略。 例如: ? 如果拋出的異常沒有與之類型相匹配的 catch語句,那么將發(fā)生非正常的程序終止( abnormal program termination )。 ? 在默認(rèn)情況下,函數(shù) terminate( )將調(diào)用 abort( )函數(shù)來終止程序,但如果需要,也可以定制自己定義的函數(shù)來終止程序的執(zhí)行。 int main( ) { int m,n。 cinmn。 cout (m/n)endl。 return 1。 } 返回 變量 arg用來接收throw拋出的異常值 拋出的異常的值與變量 arg類型不配 include iostream using namespace std。 coutPlease input two integers:。 try { if (n==0) throw 0。 } catch(char * arg) { coutargendl。 } return 0。 int division(int x, int y)。 coutPlease input two integers:。 try { coutdivision(m,n)endl。 return 1。 } 從函數(shù)內(nèi)部拋出異常 int division(int x,int y) { if (y==0) throw 0。 } 多個(gè) catch語句 void Xhandler(int test) { try{ if(test) throw test。 } catch(int i) { cout Caught One! Ex. : i 39。 } catch(char *str) { cout Caught a string: 。\n39。 Xhandler(1)。 Xhandler(0)。 cout end。 } 非正常的程序終止 include iostream using namespace std。 coutPlease input two integers:。 try { if (n==0) throw 0。 } catch(char * arg)// 拋出的異常信息的值與形參變量 arg類型不配 { coutargendl。
點(diǎn)擊復(fù)制文檔內(nèi)容
環(huán)評(píng)公示相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1