Alan,

At 04:46 PM 5/5/99 -0500, you wrote:
>I've got a constructor that does some memory allocation and creates a
>record for the app, etc. I am now trying to add nice error handling if the
>alloc's fail in the constructor, and I am at a loss for how to do this. Is
>this where you use exceptions in C++? How does that work? I have dug
>through a couple of C++ books here, but they are pretty entry-level and
>don't deal with error handling in constructors.
>
This is where you might use an exception.  However, exceptions are things
that are best used sparingly, if at all.  What we do instead is to set all
pointers to NULL in the constructor, then supply an initialization function
that performs all memory allocations.  This function can return an error if
any allocation fails.

Greg
Greg Winton
Bachmann Software and Services, LLC
mailto:[EMAIL PROTECTED]
http://www.bachmannsoftware.com
Software Development for Handheld & Mobile Computing, Windows and the Internet
Home of Bachmann Print Manager, the only graphical printing solution for
the Palm Computing Platform

Reply via email to