|
From: Ioannis V. <no...@ya...> - 2001-09-05 14:09:39
|
"The C++ Programming Language" Special Edition or 3rd Edition, on page 373, 14.4.6.1.. The compiler you are refering is probably very old. The version you provide does not catch the exceptions produced by Vector's constructor (and <iostream.h> is not ANSI C++). Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.f2s.com * Alternative URL: http://run.to/noicys > -----Original Message----- > From: Michael Codadeen [mailto:jd...@ho...]=20 > Sent: Wednesday, September 05, 2001 9:34 AM > To: no...@ya...; dev...@li... > Subject: Re: [Dev-C++] C++ question >=20 >=20 > Hi, >=20 > I have just tried this on the HPUX 10.20 aCC compiler and it does not=20 > compile. The 'try' breaks it. >=20 > Enclosing the try/catch block within braces does compile. >=20 > Out of interest which page of Stroustroups book is this on ? >=20 > Regards, >=20 > Michael > --- > Here is the compiled code for the HPUX... >=20 > #include <iostream.h> >=20 > class Exception {}; >=20 > class Vector > { > int size; >=20 > public: > Vector(int s):size(s) {} > }; >=20 > class X > { > Vector v; >=20 > public: > X(int); > }; >=20 > X::X(int s) :v(s) > { > try > { > cout <<"code run!\n"; > throw Exception(); > } >=20 > catch(Exception) > { > cout <<"Exception caught!\n"; > } > } >=20 > int main() > { > X x(3); > return 0; > } |