C++ Dynamic allocation failing code example
Example 1: C++ Dynamic allocation failing
int * foo;
foo = new (nothrow) int [5];
if (foo == nullptr) {
// error assigning memory. Take measures.
}
Example 2: C++ Dynamic allocation failing
foo = new (nothrow) int [5];
Example 3: C++ Dynamic allocation failing
foo = new int [5]; // if allocation fails, an exception is thrown