Catching All Exceptions by using catch(...) exception handler. - C++ Statement

C++ examples for Statement:try catch

Description

Catching All Exceptions by using catch(...) exception handler.

Demo Code

#include <iostream>
#include <stdexcept>

int main(int argc, const char *argv[]) {
    try {// ww w .  j  a v a2s  .com
        // throw std::exception();
        // throw std::invalid_argument("invalid argument");;
        throw std::out_of_range("out of range");
    } catch (...) {
        std::cout << "Exception Caught" << std::endl;
    }
    return 0;
}

Result


Related Tutorials