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 05:00
Pls do you believe that the use of 3d animation has grown in feature films over the last few years? if so, do you think the trend will continue? what are the forces driving this trend?
Answers: 2
question
Computers and Technology, 23.06.2019 14:30
Select the correct answer. a company wants to use online methods to target more customers. it decides to conduct a market research by collecting the data of a few customers with their consent. they want to track data of the sites that their customers frequently visit. which software can the company? a. spyware b. bots c. adware d. trojan horse e. rootkits
Answers: 1
question
Computers and Technology, 23.06.2019 18:00
While inserting images, the picture command is usually used to insert photos from a digital camera, and the clip art command is usually used to a.edit the sizes and other characteristics of photos that have been inserted. b.take a screenshot of an image and copy it to the clipboard for pasting. c.search for drawings or other images from a library of prepared pictures. d.make illustrations using lines and shapes that are easy to manipulate.
Answers: 1
question
Computers and Technology, 24.06.2019 07:30
Aproject involves many computing systems working together on disjointed task towards a single goal what form of computing would the project be using
Answers: 3
You know the right answer?
As we discussed this quarter, throwing exceptions from destructors is generally considered to be ext...
Questions
question
Social Studies, 21.12.2019 02:31
question
Spanish, 21.12.2019 02:31
question
English, 21.12.2019 02:31
question
Mathematics, 21.12.2019 02:31
question
Social Studies, 21.12.2019 02:31
Questions on the website: 13722362