home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / cplus / 15947 < prev    next >
Encoding:
Text File  |  1992-11-08  |  1.8 KB  |  56 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!pipex!warwick!bham!bhamvx!mccauleyba
  3. From: mccauleyba@vax1.bham.ac.uk (Brian McCauley)
  4. Subject: Simple exception question
  5. Sender: usenet@rs6000.bham.ac.uk (USENET News Service)
  6. Message-ID: <1992Nov9.000615.1@vax1.bham.ac.uk>
  7. Date: Mon, 9 Nov 1992 00:06:15 GMT
  8. Lines: 45
  9. Organization: University of Birmingham
  10.  
  11. I've just read the section in "The C++ Prog.Lang. Edn.2" on exception handling.
  12. I've been using C++ for a while and always found the lack of execption hadling
  13. a bit of a pain. Unfortunately my DOS compiler (Borland) lacks execption
  14. handling, still :-(
  15.  
  16. Can anybody clarify the a few points of which I was left uncertain
  17.  
  18. enum Ex1 { Ex1a, Ex1b };
  19. class Ex2 {};
  20.  
  21. try { throw Ex1a; }  
  22. catch (Ex1& ex) {
  23.   try { throw Ex2(); }
  24.   catch (Ex2) {ex=Ex1b;}
  25.   throw; // What does this throw?
  26. }
  27.  
  28. I hope the answer is Ex1b but from what I've read I'm not sure that it's not
  29. Ex1a or Ex2().
  30.  
  31. Can I throw _any_ type? This would usually be inelegant but not in the case of:
  32. I can imagine
  33.  
  34. int main() {
  35.   try { /* program body */ }
  36.   catch (int exit_status) {return exit_status;}
  37.   return 0;
  38. }
  39.  
  40. Now I can throw an int as an alternative to exit() and get the full
  41. benefit stack unwinding. In fact IMHO main() throwing an int could usefully
  42. be made to behave the same as main() returning an int.
  43. (Yes I do realise I couldn't thow an integer through a firewall unless it
  44. wanted me to, but then functions inside firewalls shouldn't be calling exit())
  45.  
  46. Does anyone know when Borland will release a version with exceptions? (I've
  47. noticed a lot of contributions from borland.com in this group.)
  48. -- 
  49.     \\   ( )  NO BULLSHIT! from BAM (Brian McCauley)
  50.  .  _\\__[oo 
  51. .__/  \\ /\@  E-mail: B.A.McCauley@bham.ac.uk
  52. .  l___\\        Fax: +44 21 625 2175
  53.  # ll  l\\     Snail: 197 Harborne Lane, Birmingham, B29 6SS, UK
  54. ###LL  LL\\     ICBM: 52.5N 1.9W
  55.  
  56.