Constructors Throwing Exceptions - C++ Statement

C++ examples for Statement:throw

Description

Constructors Throwing Exceptions

Demo Code

#include <iostream>
#include <stdexcept>

class C1 {/*  ww w  . j a  v  a2s  .  com*/
 public:
    C1() { throw 99; }
};

int main(int argc, const char *argv[]) {
    try {
        C1 c;
    } catch (int e) {
        std::cerr << "Exception: " << e << std::endl;
    }
    return 0;
}

Related Tutorials