subject

As we discussed this quarter, throwing exceptions from destructors is generally considered to be extremely problematic, so much so that we're advised never to do it. Yet C++ doesn't explicitly forbid it, so it would be possible to write a class whose destructor threw an exception. Suppose you did write such a class: class Throwing { public: Throwing() { } ~Throwing() { throw std::runtime_error{"doh!"}; } }; Are there any circumstances in which this throwing destructor would be problematic? If so, demonstrate such a circumstance (e. g., by writing a C++ function that would be problematic) and briefly explain what is problematic about it. If not, demonstrate what a problematic destructor would actually look like (i. e., what else would need to be true about it, if just throwing an exception isn't enough?). Are there any circumstances in which this throwing destructor would not be problematic? If so, demonstrate such a circumstance (e. g., by writing a C++ function where the exception would be thrown but it wouldn't cause any problems) and briefly explain why it wouldn't be a problem. If not, briefly explain whether (and why) there are any throwing destructors that ever work correctly in any circumstance.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 17:00
The most efficient way to establish top best possible economize position is to measure
Answers: 1
question
Computers and Technology, 22.06.2019 04:30
There is a simple pattern for determining if a binary number is odd. what is it and why does this pattern occur? how many bits would you need if you wanted to have the ability to count up to 1000? how high could you count in binary if you used all 10 of your fingers as bits? (finger up means 1, finger down means 0)
Answers: 3
question
Computers and Technology, 22.06.2019 14:20
Cengagenowv2 is a comprehensive online learning tool. using cengagenowv2, you may access all of the following except: 2. each time you log in, cengagenowv2 automatically performs a system check and informs you if your computer does not meet the cengagenowv2 system requirements. 3. which tab/page allows you to easily track your assignment scores, number of submissions, time spent, as well as the ability view assign
Answers: 3
question
Computers and Technology, 23.06.2019 00:00
How do we use the sumif formula (when dealing with different formats) ?
Answers: 1
You know the right answer?
As we discussed this quarter, throwing exceptions from destructors is generally considered to be ext...
Questions
question
English, 07.05.2021 14:00
question
Mathematics, 07.05.2021 14:00
question
Mathematics, 07.05.2021 14:00
question
Mathematics, 07.05.2021 14:00