home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!pipex!warwick!bham!pickerig
- From: pickerig@eee.bham.ac.uk (Guy Pickering)
- Subject: Re: Using *new* safely
- Sender: usenet@rs6000.bham.ac.uk (USENET News Service)
- Message-ID: <1992Nov19.101528.37500@rs6000.bham.ac.uk>
- Date: Thu, 19 Nov 1992 10:15:28 GMT
- References: <bruceb.722124804@babel.cltr.uq.oz.au>
- Organization: The University of Birmingham, England
- X-Newsreader: TIN [version 1.1 PL6]
- Lines: 32
-
- Bruce Blackshaw (bruceb@ctpm.uq.oz.au) wrote:
- : I'm interested in how to safely use the new operator in the constructor of
- : a complex object - if you are dynamically allocating the instance of a class
- : that itself dynamically allocates in its constructor, how do you stop crashes
- : due to failure of new?
- :
- :
- : --
- : ****************************************************
- : Bruce Blackshaw bruceb@ctpm.uq.oz.au
- : "... I'd rather be hang gliding ..."
- : ****************************************************
-
- I add an isOk() function, and keep the status in the class, when all
- allocation is complete, is set the is_ok flag to TRUE. Then after
- construction, I can call isOk() to see if all went well.
-
- The ultimate way to do it is to use exceptions, but if you don't
- have exceptions provided by your compiler...
-
- Guy
-
- --
- +--------------------------------+-----------------------------------------+
- | Guy Pickering | School of Electronic & Electrical Eng, |
- | E-MAIL: G.PICKERING@uk.ac.bham | University of Birmingham, |
- | Tel: (021) 414 4340 | Edgbaston, Birmingham. B15 2TT. |
- +--------------------------------+-----------------------------------------+
- | "I have ten pairs of trainers...One for each day of the week" - Sam Fox |
- +--------------------------------+-----------------------------------------+
-
-
-