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