Yes, since there are no return values from constructors
this is where exceptions could be used.

Exceptions are, however, a real pain & I don't know
if CW supports them.

A Q&D way of handling this sort of thing is to define
an "isOk()" method for your class that can be called
-after- the constructor:

        myObject x(param1, param2);
        if (!x.isOk()) {        
                // report error creating object
        }

-- 
-Richard M. Hartman
[EMAIL PROTECTED]

186,000 mi./sec ... not just a good idea, it's the LAW!


> -----Original Message-----
> From: Alan Pinstein [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, May 05, 1999 2:47 PM
> To: [EMAIL PROTECTED]
> Subject: Palm and C++ and constructors
> 
> 
> Hi all-
> 
> Ok, I am finishing up my first C++ Palm application, which is 
> also my 1st
> C++ app, so these questions may be very newbie as far as C++ 
> goes, but I
> know C very well.
> 
> 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.
> 
> Thanks for any advice, links, tips, etc.
> 
> 
> Alan Pinstein
> Synergy Solutions, Inc.
> http://www.synsolutions.com
> 1-800-210-5293
> 
> 
> 

Reply via email to