catch(...)是啥意思

风过云烟 2012-11-08 11:19:06
都知道try catch是可以捕抓异常,但是在看某个用C++编写的调用webservice服务的时候老是跳到异常的代码里面去,catch(...)是啥意思?
...全文
481 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
X366ING 2012-11-10
  • 打赏
  • 举报
回复
引用 2 楼 ri_aje 的回复:
捕获所有 c++ 异常,其他浮点数异常,系统异常什么的这个管不了。
学习了
Flammable_ice 2012-11-10
  • 打赏
  • 举报
回复
感觉C++的try catch捕获异常设计的不太完整,所以只能捕获一部分异常。
引用 2 楼 ri_aje 的回复:
捕获所有 c++ 异常,其他浮点数异常,系统异常什么的这个管不了。
++ 感觉C++的try catch捕获异常设计的不太完整,所以只能捕获一部分异常。
漫步者、 2012-11-10
  • 打赏
  • 举报
回复
捕捉异常的。
Binzo 2012-11-10
  • 打赏
  • 举报
回复
捕捉异常。//
max_min_ 2012-11-08
  • 打赏
  • 举报
回复
引用 楼主 xf2012 的回复:
都知道try catch是可以捕抓异常,但是在看某个用C++编写的调用webservice服务的时候老是跳到异常的代码里面去,catch(...)是啥意思?
cath(...)
{
//捕获一切异常;
}
catch(something)
{
//捕获自己抛出异常
}
luciferisnotsatan 2012-11-08
  • 打赏
  • 举报
回复
引用 2 楼 ri_aje 的回复:
捕获所有 c++ 异常,其他浮点数异常,系统异常什么的这个管不了。
+1
ri_aje 2012-11-08
  • 打赏
  • 举报
回复
捕获所有 c++ 异常,其他浮点数异常,系统异常什么的这个管不了。
JiMoKuangXiangQu 2012-11-08
  • 打赏
  • 举报
回复
捕捉一切的异常.
转角天边 2012-11-08
  • 打赏
  • 举报
回复
try...catch就是用来捕捉异常的,如果try里面的代码发生了异常,就会把异常抛到异常类,从而执行异常类对异常进行处理
赵4老师 2012-11-08
  • 打赏
  • 举报
回复
try, catch, and throw Statements C++ Specific —> C++ exception handling uses the try, catch, and throw statements to implement exception handling. With C++ exception handling, your program can communicate unexpected events to a higher execution context that is better able to recover from such abnormal events. These exceptions are handled by code that is outside the normal flow of control. Note The Win32 structured exception-handling mechanism works with both C and C++ source files. However, it is not specifically designed for C++. You can ensure that your code is more portable by using C++ exception handling. Also, C++ exception handling is more flexible, in that it can handle exceptions of any type. For C++ programs, it is recommended that you use the C++ exception-handling mechanism (try, catch, throw) described in this topic. try-block : try compound-statement handler-list handler-list : handler handler-listopt handler : catch ( exception-declaration ) compound-statement exception-declaration : type-specifier-list declarator type-specifier-list abstract-declarator type-specifier-list ... throw-expression : throw assignment-expressionopt The compound-statement after the try clause is the guarded section of code. The throw-expression “throws” (raises) an exception. The compound-statement after the catch clause is the exception handler, and “catches” (handles) the exception thrown by the throw-expression. The exception-declaration statement indicates the type of exception the clause handles. The type can be any valid data type, including a C++ class. If the exception-declaration statement is an ellipsis (...), the catch clause handles any type of exception, including a C exception. Such a handler must be the last handler for its try-block. The operand of throw is syntactically similar to the operand of a return statement. Note Microsoft C++ does not support exception-specifications, as described in section 15.4 of the ANSI C++ draft. In addition, it does not support function-try-block described in section 15 of the ANSI C++ draft. For more information on C++ exception handling, see Exception Handling Topics (C++). For information on exception handling in general, see Exception Handling: Overview. END C++ Specific Example In the following example, the try block attempts to write the headers. The catch block then handles a specific file exception, and passes all other exceptions on to the outer block with the throw macro: // Example of the try and catch statements try { // Write the file header file.Write((LPSTR)&bmfHdr, sizeof(BITMAPFILEHEADER)); // // Write the DIB header and the bits file.WriteHuge(lpBI, dwDIBSize); } catch (CFileException* e) { ::GlobalUnlock((HGLOBAL) hDib); throw; } ::GlobalUnlock((HGLOBAL) hDib); return TRUE;
luciferisnotsatan 2012-11-08
  • 打赏
  • 举报
回复
引用 4 楼 max_min_ 的回复:
引用 楼主 xf2012 的回复:都知道try catch是可以捕抓异常,但是在看某个用C++编写的调用webservice服务的时候老是跳到异常的代码里面去,catch(...)是啥意思? C/C++ code12345678cath(...){//捕获一切异常;}catch(something){//捕获自己抛出异常}
顺序反了,something永远到不了

64,642

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧