For throwing exceptions I know that you can declare/define the function with the implication that it throws an exception
EX.
void foo(void) throw(const char *) {};
What is the appropriate time to do this. If we are going to declare/define it this way, do we do it with both the prototype and the definition or just the definition. One more thing what is the syntax to do this with a constructor, if we have other stuff included.
Ex.
class bar
{
bar() , a(a) would the throw go here, and would it also in the definition if written elsewhere ?
}
Thanks 🙂
Don’t do that, it was deprecated in C++11 for a good reason: it does not do what people think it does.
Update: More information on the subject here http://www.boost.org/development/requirements.html#Exception-specification
Another update: As pointed out by @Steve Fallows, here is another good reference on the topic: http://www.gotw.ca/publications/mill22.htm