132.try throw catch介绍
#include <iostream>
using namespace std; //try尝试执行,抛出throw,throw之后语句不再执行
//catch处理throw的异常 void main()
{
float fl1, fl2;
cin >> fl1 >> fl2; //尝试执行,抛出类型检测
try
{
if (fl2 < 0.0000001)
{
throw ;
}
else if (fl1 < 0.000001)
{
throw ;
} float fl3 = fl1 / fl2;
cout << fl3 << endl;
}
//定义类型,检测判断是什么错误
catch (int code)
{
if (code == )
{
cout << "fl2太小" << endl;
}
else if (code == )
{
cout << "fl2太小" << endl;
}
} cin.get();
cin.get();
}
132.try throw catch介绍的更多相关文章
- c++ try throw catch
c++ try throw catch 这三者联合使用 , try { statement list; } catch( typeA arg ) { statement list; } catch( ...
- C++中的try throw catch 异常处理
今天在开发过程中调用一个库函数结果库函数有throw操作,当前代码没有对throw进行捕获操作,导致进程在main 函数中捕获到异常导致进程crash.所以借此记录下c++关于try,throw,ca ...
- C++ 异常处理 catch(...)介绍
转载:https://blog.csdn.net/fcsfcsfcs/article/details/77717567 catch(-)能够捕获多种数据类型的异常对象,所以它提供给程序员一种对异常 对 ...
- try throw catch
#include "stdafx.h" #include <iostream> #include <stdlib.h> using namespace st ...
- try throw catch异常处理机制
/*本程序实现分块查找算法 又称索引顺序查找 需要注意的是分块查找需要2次查找 先对块查找 再对块内查找 2013.12.16 18:44*/ #include <io ...
- try throw catch typeid
QString str = ui.ll->text(); try { if (str == NULL) { throw 1; } else { throw 1.2; } } catch (int ...
- C#中try catch中throw ex和throw方式抛出异常有何不同
我们在C#的try catch代码块中里面经常使用throw语句抛出捕捉到的异常,但是你知道吗使用throw ex和throw抛出捕获到的异常效果是不一样的. 异常捕捉的原理 首先先介绍一下C#异常捕 ...
- 【又长见识了】C#异常处理,try、catch、finally、throw
异常处理:程序在运行过程中,发生错误会导致程序退出,这种错误,就叫做异常.处理这种错误,就叫做异常处理. 1.轻描淡写Try.Catch.Finally.throw用法 在异常处理中,首先需要对可能发 ...
- [转] c++ try catch 问题
windhaunting,原文地址 以前都是用try{} catch(…){}来捕获C++中一些意想不到的异常, 今天看了Winhack的帖子才知道,这种方法在VC中其实是靠不住的.例如下面的代码: ...
随机推荐
- hdoj--1028--Ignatius and the Princess III(母函数)
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
- 【转】Core Bluetooth框架之二:后台处理
原文网址:http://southpeak.github.io/blog/2014/07/31/core-bluetoothkuang-jia-zhi-er-:hou-tai-chu-li/ 在开发B ...
- [JavaEE] Maven简介
转载自:百度 http://baike.baidu.com/view/336103.htm?fr=aladdin 一.简介 Maven是基于项目对象模型(POM),可以通过一小段描述信息来管理项目的构 ...
- Python笔记(四)
# -*- coding:utf-8 -*- # 控制语句 # if...else... print "********************1********************** ...
- Activity、Fragment、ViewPage
1.新建super //super提供统一的FragmentActivity入口.public abstract class SuperFragmentActivity extends Fragmen ...
- HD-ACM算法专攻系列(20)——七夕节
问题描述: AC源码: /**/ #include"iostream" #include"cmath" using namespace std; int mai ...
- 源码编译Oprofile
上菜了翠花:首先编译Oprofile需要三个源码:binutils.popt与oprofile Linux版(由于是在64位的linux系统编译-----敬请参考“在64位linux上编译32位程序” ...
- HDU 3830 Checkers(二分+lca)
Description Little X, Little Y and Little Z are playing checkers when Little Y is annoyed. So he wan ...
- 手机、电脑、安卓、iOS、微信浏览器判断
微信浏览器判断: // true为微信浏览器function is_weixin() { var ua = window.navigator.userAgent.toLowerCase(); if ( ...
- Android跳转到系统Wifi界面的方式
第一种 Intent intent = new Intent(); intent.setAction("android.net.wifi.PICK_WIFI_NETWORK"); ...