When an exception is thrown, how does the program know where to go? I mean, if the catch block catching the exception would have been in the same function, the throw would have been just like using a goto to the right catch block. But when there is no catch block in the same function, the compiler can't know which catch block that will catch the exception (if any at all), so the program has to figure it out in run time. But how does it do that? Does it store somewhere which type (an id) has been thrown, and looks for a catch block which catches that type?
Also, I've heard that when scopes are left due to that an exception has been thrown, all local variables are destructed. This means that new code is executed, before reaching the catch block. But what if a new exception is thrown in the mean time?
And one final question, when throwing exceptions, are there some standard exception classes you should use, or do you have to create your own?