bc++b里有没有try except结构(10分)

A

abcok

Unregistered / Unconfirmed
GUEST, unregistred user!
如果有的话清给出一个btclick
 
try
{
....
}
catch (...)
{
....
}
 
C++不是这样的,用的是catch
from msdn:
Exception Handling Syntax
Home | Overview | Howdo
I | FAQ
The structure for C++ exception handling is represented by the following syntax:
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 an exception. The compound-statement after the catch clause is the exception handler, and catches the exception thrown by the throw-expression. The exception-declaration statement after the catch clause 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 C exceptions as well as system-generated and application-generated exceptions. This includes exceptions such as memory protection, divide-by-zero, and floating-point violations. An ellipsis catch handler must be the last handler for its try block.
The operand of throw is syntactically similar to the operand of a return statement.
Microsoft Specific —>
Microsoft C++do
es not support the function exception specification mechanism, as described in section 15.4 of the ANSI C++ draft.
END Microsoft Specific
 
C++有自己的异常处理机制,既然是用C++编程,就应该用C++的思想去处理问题,不应该老局限在Delphi的世界里。
 
顶部