source:
trunk/testcase/throw-2.cpp@
2189
| Last change on this file since 2189 was 1548, checked in by , 21 years ago | |
|---|---|
|
|
| File size: 668 bytes | |
| Line | |
|---|---|
| 1 | // exceptions: multiple catch blocks |
| 2 | #include <iostream> |
| 3 | using namespace std; |
| 4 | |
| 5 | int main () |
| 6 | { |
| 7 | cout << "Hello! This has to throw an exception." << endl; |
| 8 | try |
| 9 | { |
| 10 | char * mystring; |
| 11 | mystring = new char [10]; |
| 12 | if (mystring == NULL) |
| 13 | throw "Allocation failure"; |
| 14 | for (int n = 0; n <= 100; n++) |
| 15 | { |
| 16 | if (n > 9) |
| 17 | throw n; |
| 18 | mystring[n] = 'z'; |
| 19 | } |
| 20 | } |
| 21 | catch (int i) |
