由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - Two questions about handling exceptions in C++
相关主题
A try-catch problem in C++【C++】请问这样有没有memory leak?多谢
请教一下,exception时,destructor一定会被调用么?构造函数里的异常处理
请问C++ exception后如何清理function stack上的内存资源?关于内存泄漏
C++ 的 exception handlingHelp! Virtual Destructor
几个问题some C++ interview questions
有大侠讲讲RTTI和exception的问题么?问两个问题,C++
请教个Bloomberg 的 C++ 题目请问2个类的问题
[C++] when destructors get calledone more interview question
相关话题的讨论汇总
话题: exception话题: what话题: two话题: c++话题: exceptions
进入Programming版参与讨论
1 (共1页)
h**k
发帖数: 3368
1
What happens if an exception is throws from an object's destructor?
What happens if an exception is throws from an object's constructor?
z****e
发帖数: 2024
2
1. very bad idea. not necessarily to have crash, but very well possible.
reason: when an regular exception is thrown, the destructors for existing
objects are called. if within these destructors, an other exception is
thrown, then the program will terminate immediately. very bad. none of the
exceptions are caught.
2. fine. some additional attention is needed, such like avoid naked pointers
in ctor, etc.
h**k
发帖数: 3368
3

I agree. Someone said NEVER EVER throw an exception from destructors.
pointers

【在 z****e 的大作中提到】
: 1. very bad idea. not necessarily to have crash, but very well possible.
: reason: when an regular exception is thrown, the destructors for existing
: objects are called. if within these destructors, an other exception is
: thrown, then the program will terminate immediately. very bad. none of the
: exceptions are caught.
: 2. fine. some additional attention is needed, such like avoid naked pointers
: in ctor, etc.

1 (共1页)
进入Programming版参与讨论
相关主题
one more interview question几个问题
[合集] C++ interview question help有大侠讲讲RTTI和exception的问题么?
急问:compile and build dependency请教个Bloomberg 的 C++ 题目
用包子呼唤大牛们--问关于C++Destructor的问题[C++] when destructors get called
A try-catch problem in C++【C++】请问这样有没有memory leak?多谢
请教一下,exception时,destructor一定会被调用么?构造函数里的异常处理
请问C++ exception后如何清理function stack上的内存资源?关于内存泄漏
C++ 的 exception handlingHelp! Virtual Destructor
相关话题的讨论汇总
话题: exception话题: what话题: two话题: c++话题: exceptions