?? lab12_1.cpp
字號:
// lab12_1.cpp
#include <iostream.h>
class CException
{
public:
CException(){};
~CException(){};
const char *Reason() const { return "Cexception類型的異常。"; }
};
void fn1()
{
cout<< "在子函數(shù)中觸發(fā)CException類異常" << endl;
throw CException();
}
void main()
{
cout << "進入主函數(shù)" << endl;
try
{
cout << "在try模塊中,調(diào)用子函數(shù)" << endl;
fn1();
}
catch( CException E )
{
cout << "在catch模塊中,捕獲到CException類型異常:";
cout << E.Reason() << endl;
}
catch( char *str )
{
cout << "捕獲到其它類型異常:" << str << endl;
}
cout << "回到主函數(shù),異常已被處理" << endl;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -