Mail Archives: djgpp/1998/04/28/00:18:27
Does anybody know why teh following code taken out of Stroustrup: Die
C++
Programmiersprache
Terminates whith ABORT and doen't use the Exception Handler for range
errors.
Compiler : DJGPP, GCC2.80, CWSDPMI V4.0
---------------------------------------------------------
#include<iostream>
class Range_error
{
public:
int i;
Range_error(int ii)
{
i=ii;
}
};
char to_char(int i)
{
char c=i&static_cast<unsigned char>(-1);
if (i!=c)throw Range_error(i);
return(c);
}
void main()
{
while (true)
{
cout<<endl<<"Bitte eine Zahl eingeben ";
int i;
cin>>i;
try
{
char c =to_char(i);
cout<<endl<<"Eingegeben wurde "<<c;
}
catch (Range_error x)
{
cerr<<"Huch:to char("<<x.i<<")\n";
}
}
}
--
Nils Lohmann Tel.: +49 4161 2968
Nils Lohmann Fax: +49 4161 2968
Bahnhofstr. 45c, 21614 Buxtehude eMail: lohmann AT tu-harburg DOT de
- Raw text -