ok i just started learning this exception handling thingy and i'm really confusing myself.
If exception handling used so we don't have to do error-checking too often , then why do the catch block has to come right after try block? it doesn't make sense to me..
ok so here are my questions :
- Do i have to manually throw all exceptions manually or are there exceptions that gets thrown automatically? (like new's bad_alloc fpr example , i'm guessing so i don't know)
- Whats the difference between :
Code:
try{
throw length_error("Error");
}
catch(length_error &c)
{
cout << c.what() << endl;
}
and
Code:
try{
throw "error";
}
catch(char *str)
{
cout << str << endl;
}
both work the same way !!!!
- last question .... what sensitive tasks require exception handling? (other than new)
any help is appreciated
this thing is really making me nervous