What is this kind of definition ?

1
2
char *search_and_replace_alloc(const char *str, const char *oldsubstr, 
                               const char *newsubstr) throw(bad_alloc) {}


What with the throw part ? And should I include in the declaration too ?
The only exception that this function might throw is an exception of type bad_alloc. If it throws an exception with a different type, either directly or indirectly, it cannot be caught by a regular bad_alloc-type handler.
Can't I just try-throw-catch this exception ?
If you want. That line just says that's the only exception it is *meant* to throw, so that you know to write code to catch it if you want to handle it.
Topic archived. No new replies allowed.