per gestire un'eccezzione puoi usare il costrutto try{
//codice che può produrre errore
}
catch(tipo variabile){
//gestione errore
}
invece per lanciarla:
throw "stringa";
esempio:
int Divide(int a, int b) {
if (b) return a/b;
throw "Divisione per zero";
}
Per evitare i goto potresti usare una o più funzioni.
|