Date: Fri, 08 Apr 1994 15:54:07 +0200 (MET DST) From: @imp.ch:h_ellenberger AT p14 DOT lemas DOT chg DOT imp DOT com (Hans Ellenberger) Subject: C++ exception handling To: djgpp AT sun DOT soe DOT clarkson DOT edu Lines: 48 Hello experts! I have tried almost all permutations of try, catch & throw etc. without success :-(( I thougt the code might look like the simple example below, but the compiler rejects it: //------------ verscc.cc -------------------------------------------------- #include class error { public: int ee; error(int i) {ee = i;} void report() {printf("Error %i\n",ee);} }; int xdiv(int a, int b) throw (error) // or raises error ?? { if (b==0) throw error(1); return a / b; }; main(){ //===== int i; printf("verscc.cc\n"); for (i=3; i>=0; i--){ try { printf("9/%i = %i\n",i,xdiv(9,i)); } catch (error& e){ e.report(); } } printf("Done.\n"); }; // ---- EOF --- I also tried all compiler switches like -ansi-exceptions, but then gcc complained 'unknown switch'... Many thanks and regards Hans Ellenberger