相关内容:
- 0、异常的类型可以是自定义类类型,对于类类型异常的匹配依旧是至上而下严格匹配,赋值兼容性原则在异常匹配中依然适用。一般而言,将匹配子类异常的
catch
放在上部,匹配父类异常的catch
放在下部。在工程中会定义一系列的异常类,每个类代表工程中可能出现的一种异常类型。 - 1、
C++
中直接支持异常处理的概念; - 2、
try...catch..
是C++
中异常处理的专用语句; - 3、
try
语句处理正常代码逻辑,catch
语句处理异常情况,同一个try
语句可以跟上多个catch
语句; - 4、异常处理必须严格匹配,不进行任何的转换;