PPT12
PPT12
int main() {
try {
throw 10;
}
catch (char *e) { cout << "Caught " << e; }
catch (...) { cout << "Default Exception\n"; }
return 0;
}
Output
Default Exception
// What will be the output?
int main() {
try {
throw "10";
}
catch (const char *e) { cout << "Caught " << e; }
catch (...) { cout << "Default Exception\n"; }
}
Output
Caught 10
Exception Specification
• C++ provides a mechanism to ensure that a given function is
limited to throw only a specified list of exceptions.