RAII in C++

RAII is one of the patterns in C++ to manage resources.

Sometimes at some part of the program, we need to allocate some memory and later free it.

Disaster can happen when

  1. allocateMemory() is not…