"Firstly, how does the compiler know which catch() body to use if the there are multiple catch() with the same argument."

That would be ambiguous. Which one would it use? For a compiler to decide which handler to use, the handler must differ from the other handlers. The compiler will evaluate the type that was thrown, and will determine which handler best fits the thrown type.

Neil010 wrote:

(number1[i] != ".")

Of what type is number1? I'm assuming and integral value, since double-quoted strings are pointers.

I would expect it uses the first innermost catch block that it encounters. So in the case you gave, if you throw a const char* it will always be caught by the err block, and the err2 will never be used.

I would expect it uses the first innermost catch block that it encounters. So in the case you gave, if you throw a const char* it will always be caught by the err block, and the err2 will never be used.

That is exactly what I mean. Is there any other way in which you could use the other handler?

No. Exceptions are only thrown/caught by type. If you need to have the same exception do multiple things then you might be using it wrong. Either that or you need to package the info into the exception itself.