From 4423522426449018965
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 109fba,9dc775cb38879a6d
X-Google-Attributes: gid109fba,public
X-Google-Thread: f78e5,9dc775cb38879a6d
X-Google-Attributes: gidf78e5,public
X-Google-Thread: ffc26,9dc775cb38879a6d
X-Google-Attributes: gidffc26,public
X-Google-ArrivalTime: 1994-05-18 07:20:09 PST
Path: bga.com!news.sprintlink.net!sundog.tiac.net!usenet.elf.com!rpi!usc!howland.reston.ans.net!pipex!sunic!EU.net!Austria.EU.net!gatekeeper.eeam.elin.co.at!venus!hasenberger
From: hasenberger@venus (Ronald Hasenberger)
Newsgroups: comp.sys.amiga.programmer,comp.lang.c++,comp.std.c++
Subject: Re: error handling in constructors and overloaded operators
Message-ID: <1994May18.102041.81@venus>
Date: 18 May 94 10:20:41 +1000
References: <Cpv1w6.33o@acsu.buffalo.edu>
Organization: ELIN Energieanwendung
Lines: 31
Xref: bga.com comp.sys.amiga.programmer:8935 comp.lang.c++:15800 comp.std.c++:2326


>    Suppose the constructor should fail for some reason, such as a low
> memory condition during the "el2" buffer allocation.   What is the
> best way of indicating constructor failure so that action may be taken
> by the main program ?

Use a two step initializing by having a constructor that does not (!) 
allocate any memory and for example a memeber function Create()
that does the allocation. Create could then return an error code

>    Suppose the overloaded assignment should fail for some reason, such
> as a low memory condition when allocating a new buffer for
> "obj2cls1.el2".  What is the best way of indicating assignment failure
> so that action may be taken by the main program ?

If your Compiler supports it you could use exceptions. I am not
experienced in using exceptions but at short you will have the
possibility to setup some conditions (for example low memory)
and you are able to define actions to be taken if this condition
occurs. 

Hope, I could help at least for your first problem
Ronald

-- 

-------------------------------------------------------------------------
Ronald HASENBERGER                                  Hasenberger@elin.co.at
ELIN-Energieanwendung GesmbH      	
A-1141 Vienna, Austria, Penzingerstr.76
Phone: +43 1 89100-3524                   		Fax: +43 1 8946046


