I don't know a lot about C or C++ but I think with C when you create an array you use malloc to ask for the memory and then you check that the memory was allocated before assigning values. In C++ you implement an array using new instead. Would check the allocation of memory for the array in C++ the same as in C by checking that the array is not null?
For example,
int main()
{
int* myArr = new int[10];
if(myArr!=NULL)
{
//DO SOMETHING
}
}
I get that most computers have a lot of memory, making running out of memory less likely today, but I also understand that failing to do things like this can lead to unexpected bugs later on down the road.
UPDATE: I was trying to keep my example simple. As mentioned in the comments I was referring to dynamic memory allocation. I am trying to implement a heap data structure. As part of the heap there exists an array to store the values of the heap. When the heap is full the array has to be expanded by design by the next power of 2. Thus i may initialize the heap as 10 but when I reach 10 I will need to expand to 16. Given enough items the heap will reach size 2^n. Therefore I am calling a function that has a parameter for the HEAP pointer. Then I create a new array and copy the values from the existing array to the new array. While doing this I was thinking about what happens if the new array cannot be created because of being out of memory. I may want to write the values to a file before exiting.