home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / cplus / 16555 < prev    next >
Encoding:
Text File  |  1992-11-19  |  1.8 KB  |  45 lines

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