Questions of C++ exceptions



 DEVELOP > c-Plus-Plus > Questions of C++ exceptions

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: "Wat"
Date: 04 Dec 2004 02:43:51 PM
Object: Questions of C++ exceptions
1. Is this correct in C++?
int foo() throw(); // can not throw any exception
int foo(); // can throw any exception
2. Exception specification:
int foo() throw(type list);
For example, void foo() throw(int, over_flow);
Should two catch blocks built to catch "int" and "over_flow" separately? Or
just one block of catch, which catches both "int" and "over_flow"?
3. If "int foo() throw();" does mean "can not throw any exception", then
what happens if an exception do occur inside foo()?
4. Does the above exception specification also apply to memeber functions of
classes?
Thanks for your help!
.

User: "Victor Bazarov"

Title: Re: Questions of C++ exceptions 04 Dec 2004 03:02:48 PM
"Wat" <welwat@hotmail.com> wrote...

1. Is this correct in C++?

int foo() throw(); // can not throw any exception

Yes.

int foo(); // can throw any exception

Yes.

2. Exception specification:

int foo() throw(type list);

For example, void foo() throw(int, over_flow);

Should two catch blocks built to catch "int" and "over_flow" separately?
Or
just one block of catch, which catches both "int" and "over_flow"?

There is no way in one catch block to catch two different types, unless
they are related classes and _the_base_one_ is caught by a reference or
a pointer.

3. If "int foo() throw();" does mean "can not throw any exception", then
what happens if an exception do occur inside foo()?

'unexpected()' is called.

4. Does the above exception specification also apply to memeber functions
of
classes?

Of course.
V
.


  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER