Nedd a tutorial on exception handling in C++

I haven't done much try - catch type of exception handling in c++ so I need to learn it.  For example is there a way to just trap any exception and have the code do something if that happens, or do I always have to actually specify what the problem is?
So basicaly, can I somehow do this:

try
{
 //my code - anything
}

catch (anyProblem)  //any error that would make the app crash
{
doThis;
}

I am also looking for a tutorial and/or good book on this.

Any help is appreciated,

Thanks,
axnst2
axnst2Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jkrCommented:
You'd use an ellipsis in the 'catch' statement, e.g.:

try
{
//my code - anything
}

catch (...)  //any error that would make the app crash
{
doThis();
}

The problem with this approach is that the handler cannot do much except stating "something happened" as you cannot find out of what type the exception was that got caught. Also, you cannot catch OS-specific exceptions (like SEH or signals) with that. A tuturial can be found e.g. at http://www.cplusplus.com/doc/tutorial/tut5-3.html or http://cplus.about.com/library/weekly/aa122202a.htm

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
axnst2Author Commented:
Thanks this is great.  What do I put in () at catch() for it to just catch any problem instead of crashing?
0
jkrCommented:
What OS are you on?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.