C++异常处理问题1

null

#include <iostream>
using namespace std;
int main()
{
int x = -1;
try {
cout << "Inside try " ;
if (x < 0)
{
throw x;
cout << "After throw " ;
}
}
catch ( int x ) {
cout << "Exception Caught " ;
}
cout << "After catch " ;
return 0;
}


(A)

Inside try
Exception Caught
After throw 
After catch

(B)

Inside try
Exception Caught
After catch

(C)

Inside try
Exception Caught

(D)

Inside try
After throw
After catch

答复: (B) 说明: 抛出异常时,不会执行throw语句后的try块行。

捕获异常时,执行catch块后的代码。捕捉块通常写在结尾到结尾处。 这个问题的小测验

© 版权声明
THE END
喜欢就支持一下吧
点赞8 分享