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

📄 abcexceptionchar.cpp

📁 datastucutre and algorithms, application, in C
💻 CPP
字号:
// function to compute an expression using int value parameters
// throw an exception of type char* in case one of the parameters is <= 0

#include<iostream>

using namespace std;

int abc(int a, int b, int c)
{
   if (a <= 0 || b <= 0 || c <= 0)
          throw "All parameters should be > 0";
   return a + b * c;
}

int main()
{
  try {cout << abc(2,0,4) << endl;}
  catch (char* e)
      {
         cout << "The parameters to abc were 2, 0, and 4" << endl;
         cout << "An exception has been thrown" << endl;
         cout << e << endl;
         return 1;
      }
   return 0;
}

⌨️ 快捷键说明

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