Is it possible to have automatically generated destructors in C++?
c++, c++11
Solution
Certainly it is, and that's exactly what the language does. If you don't declare a destructor, then one will be generated for you: it will invoke the destructor of each member and base subobject.
You only need to write your own destructor if you're managing a resource that isn't released automatically; for example, a raw pointer to something that you allocated with `new`. You shouldn't need such a thing in most classes - use containers, smart pointers and other RAII types to manage these automatically for you.
Problem
Is it possible to have automatically generated destructors in C++? It is too big burden to do it by ourselves all the time. Is it so hard for the compiler to generate destructors? Can't it detect what is a "resource" and release it in the destructor?