Mail Archives: djgpp/1999/06/03/16:35:17
>What does new return if it fails? I've heard that the standard requires
>that it throw an exception, but also I've heard that it returns NULL
>(like malloc). I did a test, and it did neither, preferring to exit the
>program. So, how do I capture this and use it for the greater good
>(rather than just exiting the program)?
Hmm, this is more a C++ question. Have you looked in the C++ FAQ? Maybe
it'll help you (under dynamic storage of something like that):
http://www.cerfnet.com/~mpcline/c++-faq-lite/
Hope that helps, else you might consider trying the comp.lang.c++
newsgroup.
I have never tried using exceptions myself so unfortunately I can't answer
you question directly, but at least I know that 'new' never returns 0...
BTW, are you using an old version of the C++ compiler? If so you'd better
upgrade because I think some of the older versions had problems with
exception.
Ole Laursen
- Raw text -