If an error occurs in our program, we want to be able to handle it in some way. One way to do this is through
exceptions.
Exceptions are mechanisms where we try to execute some code in the try{} block, and if an error occurs, an exception is thrown. The control is then transferred to a catch clause, which handles that exception. A structure of a try/catch block would be:
int main()
{
try
{
// your code here
// throw an exception if there is an error
}
catch (type_of_the_exception e)
{ ...