memory allocation in C++ is performed via the new operator. It
returns NULL if it fails. General form:
Code:
datatype *pointer;
if ((pointer = new datatype) == NULL)
cout << "Alocation failed";
for arrays, it would be new datatype [size]
delete is used to free the memory, or []delete if an array was allocated to the pointer (no need to specify the size inside of [])
There is no realloc equivalent in C++, so if you need to resize,
allocate new memory, copy the stuff from the old memory and
delete the old pointer.