正在加载图片...
Catching an exception J Use single or multiple catch sentences to catch thrown exception objects extern void log message(const char*) catch(const char* str) extern string err message i log message(str) extern ostream log file status= false catch(iterator overflow& iof) bool funcAO i lof. what happened(log file) status=false; j bool status= true return statu catch(int errno) i log message(err message[errno].c strO) status=false; j a It could handle our previous 3 exception objects throw 42, throw“ panIc: no buffer!”; a throw iterator_overflow(m_iIdx, Fibonacci: m_iMaxElems)Catching an exception ◼ Use single or multiple catch sentences to catch thrown exception objects extern void log_message(const char*); extern string err_message[]; extern ostream log_file; bool funcA() { bool status = true; //… catch (int errno) { log_message(err_message[errno].c_str()); status = false; } catch (const char* str) { log_message(str); status = false; } catch (iterator_overflow& iof) { iof.what_happened(log_file); status = false; } return status; } ◼ It could handle our previous 3 exception objects: ◼ throw 42; ◼ throw “panic: no buffer!”; ◼ throw iterator_overflow(m_iIdx, Fibonacci::m_iMaxElems);
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有