I know just the basics of C++ exception handling but as far as I can see, Java has excplicit Object
-based hierarchy for exceptions (Throwable
, Exception
, RuntimeException
, Error
) while in C++ you can do
try
{
throw 1337;
}
catch (int i)
{
// i == 1337
}
This of course reflects to the design of your class structures and general exception handling policies etc.
Other difference introduced by this seemingly minor difference is that C++ really only has what would be known as Runtime Exceptions in Java world, which means that you can throw anything at any time without explicitly writing code to handle the throw pseudo-exception (I'm not willing to call int
or any other primitive type an exception, they're just possibly exceptional values).
Lastly, due to their nature when compared to Java's exceptions C++ exceptions don't by default contain anything comparable to Java's stacktraces.