Nedd a tutorial on exception handling in C++

Posted on 2004-11-04
Last Modified: 2006-11-17
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:

 //my code - anything

catch (anyProblem)  //any error that would make the app crash

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

Any help is appreciated,

Question by:axnst2
    LVL 86

    Accepted Solution

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

    //my code - anything

    catch (...)  //any error that would make the app crash

    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 or


    Author Comment

    Thanks this is great.  What do I put in () at catch() for it to just catch any problem instead of crashing?
    LVL 86

    Expert Comment

    What OS are you on?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
    Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
    The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
    The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now