// Programm zur Demonstration verschiedener catch-Bloecke
#include <iostream>
using namespace std;

// Tuwas wird unterschiedliche Typen werfen, je nach dem
// Wert des Parameters Problem.
void Tuwas(int Problem)
{
    switch (Problem)
    {
    case 0: throw 5; break;                  // wirft int
    case 1: throw (char *)"test.dat"; break; // wirft char *
    case 2: throw 2.1; break;                // wirft double
    case 3: throw 'c'; break;                // wirft char
    }
}

// Testprogramm
int main()
{
    // Problem-Nummer eingeben
    int Auswahl;
    cout << "Zahl zwischen 0 und 3 eingeben:" << endl;
    cin >> Auswahl;
    // Der try-Block fät die Exception in Tuwas
    try
    {
        Tuwas(Auswahl);
    }
    catch(int i) 
    {
        cout << "Integer " << i << endl;
    }
    catch(char *s) 
    {
        cout << "Zeichenkette " << s << endl;
    }
    catch(double f) 
    {
        cout << "Kommazahl " << f << endl;
    }
    catch(...) // fuer alle anderen Exception-Typen
    {
        cout << "Allgemeinfall" << endl;
    }
}