Deterministic object destruction is probably my favorite feature of C++ that is found in only a select few other languages. When execution leaves a function or any other scope, be it regularly or through an exception, all local objects get destroyed and their destructors executed. Not eventually when a garbage connector feels like cleaning up some leftovers but immediately. This includes the automatic destruction of that class' member objects.
That means there's also no need for finally: cleaning up all those file handles, memory allocations and network sockets and painting the sky blue again is done automagically by the destructors of properly written filestreams, smart pointers, socket classes and temporary sky blackeners.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Deterministic object destruction is probably my favorite feature of C++ that is found in only a select few other languages. When execution leaves a function or any other scope, be it regularly or through an exception, all local objects get destroyed and their destructors executed. Not eventually when a garbage connector feels like cleaning up some leftovers but immediately. This includes the automatic destruction of that class' member objects.
That means there's also no need for
finally
: cleaning up all those file handles, memory allocations and network sockets and painting the sky blue again is done automagically by the destructors of properly written filestreams, smart pointers, socket classes and temporary sky blackeners.