CompuServe Messages

#Handle Err In Constructr

    10-Jul-94 11:26:30
Fm: Gary Capps 74634,3377
To: Kwong-hip Chan 70164,112
KC> Please show me a way to handle errors inside KC> a constructor. A constructor does not return KC> a value. It cannot return a NULL or FALSE KC> to the parent program that the constructor KC> encounters an error. About your only choice is to throw an exception. Unfortunately, until VC++ 2.0 is released, Microsoft's "pseudo" exception mechanism — really just Windows' version of setjmp()/longjmp() calls wrapped in macros — can cause problems of its own because it doesn't unwind the stack. This means that the destructors of objects declared on the stack don't get called which can result in memory leaks (or worse). gc Norman, Oklahoma USA — "Is that a *real* poncho or is that a *Sears* poncho?"