Mail Archives: djgpp/1994/04/08/20:30:39
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 <stdio.h>
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
- Raw text -