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, 23.06.2019 04:00
In a word processing program, such as microsoft word, which feature to you choose the desired picture enhancement?
Answers: 2
question
Computers and Technology, 23.06.2019 11:30
Auser is given read permission to a file stored on an ntfs-formatted volume. the file is then copied to a folder on the same ntfs-formatted volume where the user has been given full control permission for that folder. when the user logs on to the computer holding the file and accesses its new location via a drive letter, what is the user's effective permission to the file? a. read b. full control c. no access d. modify e. none of the above
Answers: 1
question
Computers and Technology, 23.06.2019 15:00
Based on the current economic situation do you expect the employment demand for graduating engineers to increase or decrease? explain the basis for your answer. with a significant economic recovery, what do you think will happen to future enrollments in graduating engineering programs?
Answers: 1
question
Computers and Technology, 23.06.2019 20:10
Leo is a recruitment executive for a large company. he has identified new labor resource requirements in both the marketing and production departments. what should be his first step in recruiting candidates for the positions? a. conduct background checks of candidates b. make job offers c. arrange interviews d. conduct reference checks e. place job ads on job sites
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, 25.01.2022 01:30
question
Mathematics, 25.01.2022 01:30
question
Mathematics, 25.01.2022 01:30
Questions on the website: 13722367