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 :
andCode:try{ throw length_error("Error"); } catch(length_error &c) { cout << c.what() << endl; }
both work the same wayCode:try{ throw "error"; } catch(char *str) { cout << str << endl; }!!!!
- last question .... what sensitive tasks require exception handling? (other than new)
any help is appreciated
this thing is really making me nervous



LinkBack URL
About LinkBacks
!!!!



AFAIK, the catch block doesn't have to come right after the throw. I sort-of think of exception processing as a special case GOTO. It breaks the normal flow of your program.