Exception Speicfication
-
class Exception{}; //warning C4290: C++ Exception Specification ignored void ExceptionSepcification()throw(Exception) { throw Exception(); } void WithOutExceptionSepcification() { throw Exception(); } void main() { try { ExceptionSepcification(); //Or call WithOutExceptionSepcification(); } catch(Exception& e) { cout<<"Exception caught"; } } Both the Function ExceptionSepcification and WithOutExceptionSepcification throws Exception. The what does the throw in Below statement makes difference void ExceptionSepcification()throw(Exception)
VIBIN "Fool's run away,where angle's fear to tread"
-
class Exception{}; //warning C4290: C++ Exception Specification ignored void ExceptionSepcification()throw(Exception) { throw Exception(); } void WithOutExceptionSepcification() { throw Exception(); } void main() { try { ExceptionSepcification(); //Or call WithOutExceptionSepcification(); } catch(Exception& e) { cout<<"Exception caught"; } } Both the Function ExceptionSepcification and WithOutExceptionSepcification throws Exception. The what does the throw in Below statement makes difference void ExceptionSepcification()throw(Exception)
VIBIN "Fool's run away,where angle's fear to tread"
-
class Exception{}; //warning C4290: C++ Exception Specification ignored void ExceptionSepcification()throw(Exception) { throw Exception(); } void WithOutExceptionSepcification() { throw Exception(); } void main() { try { ExceptionSepcification(); //Or call WithOutExceptionSepcification(); } catch(Exception& e) { cout<<"Exception caught"; } } Both the Function ExceptionSepcification and WithOutExceptionSepcification throws Exception. The what does the throw in Below statement makes difference void ExceptionSepcification()throw(Exception)
VIBIN "Fool's run away,where angle's fear to tread"
In brief, don’t bother with exception specifications. Even experts don’t bother. The main problems with exception specifications are that they’re only “sort of” part of the type system, they don’t do what most people think, and you almost always don’t want what they actually do. http://www.gotw.ca/gotw/082.htm[^] http://herbsutter.spaces.live.com/blog/cns!2D4327CC297151BB!149.entry[^]
Florin Crisan