Frage zu Try Catch und Exeptions
-
Hallo alle zusammen,
Folgender Code:
Rechnung toread; try { fstream file(rechnrtodatname(rechnr), ios::in|ios::binary); if(file.is_open()) file.write((const char*)&toread,sizeof(toread)); if(file.bad()) return(toread);//Wenn ich hier ankomme soll er eine Execption auslösen } catch(...) { //Hier kommt dann ein Std error mit Msg Box }Macht mir sorgen.
Ich würde gerne selbst eine Execption auslösen um in den Catch Block zu kommen.
Wie mache ich das??Wenn jemand ne gute Seite zu Execptions her damit
.
-
Hallo,
Exceptions löst man mit throw aus. Schau einfach mal in die BCB-Hilfe dazu.
oder hier
http://www.hlrs.de/people/mueller/tutorials/script/scriptch6.html#x59-1550006
http://tutorial.schornboeck.net/exceptions.htm
-
Vielen Dank
-
Noch etwas mehr
http://www.highscore.de/cpp/aufbau/exceptions.html
http://www.zfx.info/Tutorials.php?ID=82
http://www.c-plusplus.net/forum/viewtopic-var-t-is-139074.html