This article is a junior engineer’s idea of what a senior engineer should know.
(Although "this is bad practice, I've never done it, I didn't care to look up details" would be a perfectly fine answer to me if I was the interviewer)
It’s no longer the C++ from 20 years ago.
Raising exceptions in a destructor sounds even more fun than a “return” statement inside a Python “finally” block of a method.
The footgun store will never go out of business!!!
The fact that C++ programming books have entire sections about destructors (see: Effective C++) shows that this is very much not irrelevant minutiae. C++ forces you to deal with this kind of detail all the time.
Now, we can have a much more interesting discussion about whether C++ is a disaster of a language precisely because you are forced to deal with this kind of minutiae by hand. We could also have an interesting discussion about whether RAII is the "object oriented" of our time. We could even have an interesting discussion as to why so many companies ban constructors/destructors in their C++ programming guidelines.
However, irrelevant minutiae C++ destructors are not.
I hate this style of interviewing which is more about the interviewer feeling good about themselves rather than doing their job and assessing candidates. Just wastes everyone's time all around.
supliminal•2h ago