⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch9.2mverr.cc

📁 C++ source code for book-C++ and Object Oriented Numeric computing for scientists and engineers
💻 CC
字号:
#include <iostream> 

class MVerr { };                         // a base class
class Overflow: public MVerr { };        // overflow

class IntOverflow: public Overflow { };     // integer overflow
class FloatOverflow: public Overflow { };   // floating number overflow

class SmallDivisor2: public MVerr { };    // small or zero divisor
class NoMatch: public MVerr { };          // matrix vector size not match

void f() {
  try {
    // ... try some code
    throw IntOverflow();

  } catch (Overflow) {
    // ... handle integer, floating number overflow and derived exceptions
    std::cout << "handling overflow" << std::endl;

  } catch (MVerr) {
    // ... handle MVerr errors that are not Overflow
  }
}


void g() {
  try {
    // ... try some code
    throw NoMatch();

  } catch (Overflow) {
    // ... handle integer, floating number overflow and derived exceptions
    std::cout << "handling overflow" << std::endl;

  } catch (MVerr) {
    // ... handle MVerr errors that are not Overflow
    std::cout << "handling non-overflow matrix-vector exceptions" << std::endl;
  }
}


int main() {
  f();
  g();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -