CPlusPlusThings/practical_exercises/10_day_practice/day9/exception/6.cpp

23 lines
344 B
C++

// Eg10-6.cpp
#include <iostream>
using namespace std;
void Errhandler(int n) throw() {
try {
if (n == 1)
throw n;
if (n == 2)
throw "dx";
if (n == 3)
throw 1.1;
} catch (...) {
cout << "catch an exception..." << endl;
}
}
int main() {
Errhandler(1);
Errhandler(2);
Errhandler(3);
return 0;
}