What is the best way to deal with memory allocation errors? Do some compilers throw an exception and others return null?
ORCode:try { int * x = new int[10]; } catch (bad_alloc) { cout << "out of memory" << endl; }
I feel one is C++ and the other C.Code:int * x = new int[10]; if(x == NULL) cout << "out of memory" << endl;