The beginning In basic terms, C’s memory management gives us ‘the stack‘ and ‘the heap‘; the former used automatically by variables with function-scope, and the latter provided by C’s malloc/free and C++’s new/delete. Managing memory allocated from the heap turns out to be error prone, with the possibility of memory leaks, double deletions, dangling pointers, and so on. All of these problems are caused by the fact that it’s up to the programmer to correctly match every new with one delete, with no restriction on said programmer from using unstructured/spaghetti-code in their buggy attempts to achieve this goal. On the other hand, memory allocated from the stack is extremely predictable — the point of construction and destruction of every object follows a strict structure that makes…