Exemplo n.º 1
0
void Essai3()
{
    cout << "----- 3. Gestion de plusieurs exceptions simultanement ---" << endl;
    // A COMPLETER : Traitez TOUTES les exceptions susceptible d'etre lancee par le bloc de code suivant (try...catch)

    // ...
    {
        Employee e;
        cout << "Encodez un nouvel employe :" << endl;
        cin >> e;
        cout << "Saisissez son mot de passe : ";
        char txt[80];
        cin.getline(txt,80,'\n');
        try {
            e.setPassword(txt);
        } catch(InvalidPasswordException ex) {
            e.display();
        }
        cout << endl << "Voici l'employe encode :" << endl;
        cout << e << endl;
        cout << "et son mot de passe : " << e.getPassword() << endl << endl;
        cout << "Nouvelle fonction : ";
        cin.getline(txt,80,'\n');
        try {
            e.setFunction(txt);
        } catch(InvalidFunctionException ex) {
            e.display();
        }
        cout << "Voici la nouvelle fonction encodee : " << e.getFunction() << endl;
    }
    // ...

    cout << endl;
}