Can someone explain me why exception handling is used?
I have the following example:
I know how it works, you give an id to the constructor from the class: CInvalidArgumentsException and generate an error that you ask in the catch.
using namespace std;
Matrix matrix1 = Matrix(10,10);
else (do something)
cout << "error\n";
What i'm not sure of is, is it necessary to always test in the try catch block with an if test to trow the exception? If this is the only way is it not easier to print the error out in the if test?
I am used to programming in C.