On this, just to mention that new throws an bad alloc exception it doesn't return nullptr on error like malloc does. You can use

Type *t = new(std::nothrow) Type;
to get the no-throw version that...