++ throw ( ).
try {
throw 42;
} catch(int e) {
std::cout << "Caught: " << e << "\n";
}
, ++, , , , .
, - std::exception. , , , . , , , , .
, , : , std::exception; , .
Such exception hierarchies are much easier to maintain and reason about whether you save exception types different from other types used in your program. In addition, this guide makes it less attractive for people to abuse exceptions as glorified return values, which you should never do.
source
share