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

📄 lt04.cpp

📁 一、教学目的: 能理解C++中运算符重载的需要性
💻 CPP
字号:
int j;
double d;
char str[20];

class Coords
{
   public:
      Coords(double a,double b);
      //...
};

class String
{
   public;
      String(char *);
      //...
};

void f()
{
   try
   {
      //...
      throw 10;
      //...

      throw j;        //j为int型
      //...
      throw d;        //d为double型
      throw "abc";
      //...

      throw str;      //字符串
      //...

      throw Coords(1.0,3.0);
      //...

      throw String("def");
    }

  catch(int k)
  {
  //...
  }

  catch(double x)
  {
  //...
  }

  catch(char * ptr)
  {
  //...
  }

  catch(Coords c)
  {
  //...
  }

  catch(String s)
  {
  //...
  }
  
  cout<<"That is ok.\n";
}

⌨️ 快捷键说明

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