| Line |  | 
|---|
| 1 | // This example illustrates a conditional expresion | 
|---|
| 2 | // used as a throw expression. | 
|---|
| 3 |  | 
|---|
| 4 | #include <iostream.h> | 
|---|
| 5 | void main() { | 
|---|
| 6 | int doit = 1; | 
|---|
| 7 | int dont = 0; | 
|---|
| 8 | float f = 8.9; | 
|---|
| 9 | int i = 7; | 
|---|
| 10 | int j = 6; | 
|---|
| 11 | try { throw(doit ? i : f); } | 
|---|
| 12 | catch (int x) | 
|---|
| 13 | { | 
|---|
| 14 | cout << "Caught int " << x << endl; | 
|---|
| 15 | } | 
|---|
| 16 | catch (float x) | 
|---|
| 17 | { | 
|---|
| 18 | cout << "Caught float " << x << endl; | 
|---|
| 19 | } | 
|---|
| 20 | catch (double x) | 
|---|
| 21 | { | 
|---|
| 22 | cout << "Caught double " << x << endl; | 
|---|
| 23 | } | 
|---|
| 24 | catch (...) | 
|---|
| 25 | { | 
|---|
| 26 | cout << "Caught something " << endl; | 
|---|
| 27 | } | 
|---|
| 28 | } | 
|---|
| 29 |  | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.