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, 22.06.2019 19:20
Amedian in the road will be marked with a white sign that has a black arrow going to the left of the median. true false
Answers: 1
question
Computers and Technology, 23.06.2019 14:00
Technician a says that with self-adjusting clutch systems, the release bearing constantly rotates. technician b says that the ball bearing portion of the release bearing should be lubricated with high-temperature grease during routine maintenance. which technician is correct?
Answers: 2
question
Computers and Technology, 23.06.2019 15:00
Barbara is interested in pursuing a career in the science and math pathway. which qualifications will her reach that goal? a.an advanced knowledge of physics and math b.an advanced knowledge of engineering and math c. an advanced knowledge of physics and robotics an d. advanced knowledge of machinery and math
Answers: 1
question
Computers and Technology, 23.06.2019 21:00
Which task uses a simple parameter?
Answers: 1
You know the right answer?
As we discussed this quarter, throwing exceptions from destructors is generally considered to be ext...
Questions
question
Mathematics, 19.11.2019 08:31
question
History, 19.11.2019 08:31
question
Mathematics, 19.11.2019 08:31
question
English, 19.11.2019 08:31
question
Mathematics, 19.11.2019 08:31
Questions on the website: 13722362