I see in C++ there are multiple ways to allocate and free data and I understand that when you call malloc you should call free and when you use the
malloc
free
The new and delete operators can operate on classes and structures, whereas malloc and free only work with blocks of memory that need to be cast.
new
delete
Using new/delete will help to improve your code as you will not need to cast allocated memory to the required data structure.
new/delete