C 第29页
C++异常处理问题11-yiteyi-C++库

C++异常处理问题11

当异常被抛出而没有被捕获到任何地方,比如跟踪程序时,C++中会发生什么。 #include <iostream> using namespace std; int fun() throw ( int ) { throw 10; } int main() { fun(); retur...
CPPKU的头像-yiteyi-C++库CPPKU3年前
399
C++异常处理问题10-yiteyi-C++库

C++异常处理问题10

关于C++中异常处理的哪一个是正确的? 1) Java中有一个标准的异常类,比如exception类。 2)C++中所有的异常都是未检查的,即编译器不检查是否捕获异常。 3)在C++中,函数可以使用使用逗号分...
CPPKU的头像-yiteyi-C++库CPPKU3年前
5711
C++异常处理问题9-yiteyi-C++库

C++异常处理问题9

#include <iostream> using namespace std; class Test { static int count; int id; public : Test() { count++; id = count; cout << 'Constructing object number ' << id...
CPPKU的头像-yiteyi-C++库CPPKU3年前
5310
C++异常处理问题8-yiteyi-C++库

C++异常处理问题8

#include <iostream> using namespace std; class Test { public : Test() { cout << 'Constructing an object of Test ' << endl; } ~Test() { cout << 'Destructing ...
CPPKU的头像-yiteyi-C++库CPPKU3年前
3511
C++异常处理问题7-yiteyi-C++库

C++异常处理问题7

#include <iostream> using namespace std; int main() { try { try { throw 20; } catch ( int n) { cout << 'Inner Catch' ; throw ; } } catch ( int x) { cout << 'Outer...
CPPKU的头像-yiteyi-C++库CPPKU3年前
516
C++异常处理问题6-yiteyi-C++库

C++异常处理问题6

#include <iostream> using namespace std; int main() { try { throw 10; } catch (...) { cout << 'default exception' ; } catch ( int param) { cout << 'int exception'...
CPPKU的头像-yiteyi-C++库CPPKU3年前
5014
C++异常处理问题5-yiteyi-C++库

C++异常处理问题5

#include <iostream> using namespace std; int main() { try { throw 'a' ; } catch ( int param) { cout << 'int exception' ; } catch (...) { cout << 'default exceptio...
CPPKU的头像-yiteyi-C++库CPPKU3年前
4610
C++异常处理问题4-yiteyi-C++库

C++异常处理问题4

以下程序的输出 #include<iostream> using namespace std; class Base {}; class Derived: public Base {}; int main() { Derived d; try { throw d; } catch (Base b) { cout<< 'C...
CPPKU的头像-yiteyi-C++库CPPKU3年前
5610
C++异常处理问题3-yiteyi-C++库

C++异常处理问题3

什么应该放在一个盒子里 尝试 块 1. Statements that might cause exceptions 2. Statements that should be skipped in case of an exception (A) 只有一个 (B) 只有两个 (C) 1和2 答复:...
CPPKU的头像-yiteyi-C++库CPPKU3年前
5110
C++异常处理问题1-yiteyi-C++库

C++异常处理问题1

#include <iostream> using namespace std; int main() { int x = -1; try { cout << 'Inside try ' ; if (x < 0) { throw x; cout << 'After throw ' ; } } catch ( int ...
CPPKU的头像-yiteyi-C++库CPPKU3年前
348
C++模板2题-yiteyi-C++库

C++模板2题

预测产量? #include <iostream> using namespace std; template < typename T> void fun( const T&x) { static int count = 0; cout << 'x = ' << x << ' c...
CPPKU的头像-yiteyi-C++库CPPKU3年前
356
C++遗传问题8-yiteyi-C++库

C++遗传问题8

#include<iostream> using namespace std; class Base { public : int fun()  { cout << 'Base::fun() called' ; } int fun( int i)  { cout << 'Base::fun(int i) called'...
CPPKU的头像-yiteyi-C++库CPPKU3年前
517