Destructors in C++
Destructor Rules
First and foremost, destructors must deallocate all the memory requested by the object throughout its lifecycle, close any files and connections and generally return all resources its object has acquired. If none of these acquisitions has happened, there is no need to define a destructor.
Additionally:
- A base class destructor should be either public and virtual, or protected and nonvirtual
- A destructor may not fail
- Make destructors
noexcept