4 ms·
>One need to write it manually each time in each function where some cleanup is needed. You can structure your code to not need cleanup in every function. The
by cv5005 5mo ago
>One need to write it manually each time in each function where some cleanup is needed.
You can structure your code to not need cleanup in every function.
The biggest problem with destructors is, how do you handle errors? close() can fail you know?
- Panzerschrek 5mo agoUsually destructors can't fail. But for rare cases like with close() you can write a helper function (static method) which destroys the given object and returns an error if has one.