dev-cpp-users Mailing List for Dev-C++
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
You can subscribe to this list here.
2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(15) |
Oct
(115) |
Nov
(154) |
Dec
(258) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(377) |
Feb
(260) |
Mar
(249) |
Apr
(188) |
May
(152) |
Jun
(150) |
Jul
(195) |
Aug
(202) |
Sep
(200) |
Oct
(286) |
Nov
(242) |
Dec
(165) |
2002 |
Jan
(245) |
Feb
(241) |
Mar
(239) |
Apr
(346) |
May
(406) |
Jun
(369) |
Jul
(418) |
Aug
(357) |
Sep
(362) |
Oct
(597) |
Nov
(455) |
Dec
(344) |
2003 |
Jan
(446) |
Feb
(397) |
Mar
(515) |
Apr
(524) |
May
(377) |
Jun
(387) |
Jul
(532) |
Aug
(364) |
Sep
(294) |
Oct
(352) |
Nov
(295) |
Dec
(327) |
2004 |
Jan
(416) |
Feb
(318) |
Mar
(324) |
Apr
(249) |
May
(259) |
Jun
(218) |
Jul
(212) |
Aug
(259) |
Sep
(158) |
Oct
(162) |
Nov
(214) |
Dec
(169) |
2005 |
Jan
(111) |
Feb
(165) |
Mar
(199) |
Apr
(147) |
May
(131) |
Jun
(163) |
Jul
(235) |
Aug
(136) |
Sep
(84) |
Oct
(88) |
Nov
(113) |
Dec
(100) |
2006 |
Jan
(85) |
Feb
(119) |
Mar
(33) |
Apr
(31) |
May
(56) |
Jun
(68) |
Jul
(18) |
Aug
(62) |
Sep
(33) |
Oct
(55) |
Nov
(19) |
Dec
(40) |
2007 |
Jan
(22) |
Feb
(49) |
Mar
(34) |
Apr
(51) |
May
(66) |
Jun
(43) |
Jul
(116) |
Aug
(57) |
Sep
(70) |
Oct
(69) |
Nov
(97) |
Dec
(86) |
2008 |
Jan
(32) |
Feb
(47) |
Mar
(106) |
Apr
(67) |
May
(28) |
Jun
(39) |
Jul
(31) |
Aug
(25) |
Sep
(18) |
Oct
(25) |
Nov
(5) |
Dec
(21) |
2009 |
Jan
(33) |
Feb
(27) |
Mar
(27) |
Apr
(22) |
May
(22) |
Jun
(10) |
Jul
(17) |
Aug
(9) |
Sep
(21) |
Oct
(13) |
Nov
(4) |
Dec
(11) |
2010 |
Jan
(10) |
Feb
(8) |
Mar
(4) |
Apr
(1) |
May
|
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(8) |
Oct
(26) |
Nov
(9) |
Dec
(1) |
2011 |
Jan
(21) |
Feb
(16) |
Mar
(4) |
Apr
(19) |
May
(26) |
Jun
(9) |
Jul
(6) |
Aug
|
Sep
(4) |
Oct
(3) |
Nov
(2) |
Dec
(1) |
2012 |
Jan
(4) |
Feb
(7) |
Mar
(4) |
Apr
|
May
(1) |
Jun
(10) |
Jul
(1) |
Aug
(1) |
Sep
(18) |
Oct
(3) |
Nov
(1) |
Dec
(1) |
2013 |
Jan
(4) |
Feb
(2) |
Mar
(15) |
Apr
(6) |
May
(1) |
Jun
(3) |
Jul
(1) |
Aug
(2) |
Sep
(4) |
Oct
|
Nov
(9) |
Dec
|
2014 |
Jan
(4) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(5) |
Aug
(4) |
Sep
|
Oct
(2) |
Nov
(1) |
Dec
(4) |
2015 |
Jan
(2) |
Feb
(3) |
Mar
(1) |
Apr
(2) |
May
(1) |
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(2) |
Oct
(9) |
Nov
(35) |
Dec
(6) |
2016 |
Jan
(7) |
Feb
(10) |
Mar
(10) |
Apr
(9) |
May
(13) |
Jun
(9) |
Jul
(1) |
Aug
(3) |
Sep
(3) |
Oct
(1) |
Nov
(1) |
Dec
|
2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2019 |
Jan
(1) |
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2020 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
|
|
|
|
|
|
1
(2) |
2
(2) |
3
(9) |
4
(11) |
5
(15) |
6
(5) |
7
|
8
(1) |
9
(2) |
10
(8) |
11
(4) |
12
(4) |
13
(5) |
14
(5) |
15
(10) |
16
(14) |
17
(7) |
18
(2) |
19
|
20
(7) |
21
(12) |
22
(6) |
23
|
24
(4) |
25
(6) |
26
(16) |
27
(9) |
28
(7) |
29
(18) |
30
(9) |
|
|
|
|
|
|
From: Ioannis V. <no...@ya...> - 2001-09-05 22:43:45
|
> -----Original Message----- > From: dev...@li...=20 > [mailto:dev...@li...] On Behalf=20 > Of Michael C > Sent: Wednesday, September 05, 2001 11:56 PM > To: Ioannis Vranos; Dev-C++ > Subject: Re: [Dev-C++] C++ question >=20 >=20 > As stated in the previous email, I agree. >=20 > However, it would be interesting to see what happens if you=20 > make an object in the initialiser list consistantly fail on=20 > construction-initialisation. Then when the exception is=20 > caught in the catch block, construct the object again. A=20 > recursive construction-failure scenario as you suggest. Yes. >=20 > If the compiler is clever enough it should report this as a=20 > warning. I guess it can not report this as an error as it=20 No, i have done already this by calling this->X(7); when we were discussing the matter for first time and it compiled ok of course since it is not a syntax error but a logical. The resulting exe fell in infinite recursion (printing the same 2 messages the whole time). The compiler must be clever catching the syntax errors and not the logical. If it was so logical, it could write the program itself. :) > doesn't stop you from programming recursive functions in=20 > general, and you could forget the base test in one of these=20 > and hang your program. Yes, it can't report it as an error, recursion is not an error as a concept 9although it must be avoided). >=20 > I may try this out this weekend. >=20 > When you say 'continue below the catch block' I guess this is=20 > a typo and you mean within the catch block. I don't think you=20 > can have another block under the catch block as this would be=20 > outside the scope of the constructor. Yes, that message was before the other you answered first, which stated that the end of the function is at the end of the catch block. In summary, we can't write outside the catch block. Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.f2s.com * Alternative URL: http://run.to/noicys |
From: Ioannis V. <no...@ya...> - 2001-09-05 22:33:01
|
> -----Original Message----- > From: Michael C [mailto:jd...@ho...]=20 > Sent: Wednesday, September 05, 2001 11:40 PM > To: Ioannis Vranos; Dev-C++ > Subject: Re: [Dev-C++] C++ question >=20 >=20 > O.K. for argument sake I agree with you. > I agree that the catch block is the end of the constructor=20 > only when it is present. >=20 > What I would like to know is what happens when you have an=20 > initialiser list of two or more objects that you want to=20 > place a try against. >=20 > Would you have the following ? >=20 > X () try : a(1), b(2), c(3) > { > ... > } >=20 > How would you determine in the catch who threw the exception=20 > ? I guess each object could throw a different kind of=20 > exception and there could be a catch for each kind. But if=20 > they all throw the same kind of exception I guess you would=20 > need some sort of identification in that exception to=20 > correlate it to the offending object. Of course. or you can use inheritance and polymorphism to exception types, like the following style: class Except { public: virtual void showdata()=3D0; }; class Error1: public Except { void showdata() { std::cout<<"Error of type 1\n; } }; class Error2: public Except { void showdata() { std::cout<<"Error of type 2\n"; } }; // ... catch(Except &e) { e.showdata(); } Stroustrup has all these in the same chapter. For abstracting system dependencies you can use multiple inheritance. >=20 > As I am using an older compiler, HPUX 10.20, I cannot play=20 > with this myself. When I move to HPUX 11, I'll be able to try it out. You don't have Winblowz with Dev-C++? Why you don;t download the latest gcc at least. 3.01 is excellent. >=20 > Have you tried the above ? yes your code with the 3 objects compiles too (provided that constructor X() is modified to accept 3 arguments). >=20 > Michael Now a surprise. this thing doesn't apply only to constructors but to all kinds of functions! See the code (it compiles): void f() try { 1+1; } catch(...) { } int main() {} I saw it in next page of Special Edition (374). In that page see the first 2 code fragments (that means that the following days i shall see much Light). :) Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.f2s.com * Alternative URL: http://run.to/noicys |
From: Michael C <jd...@ho...> - 2001-09-05 21:49:18
|
As stated in the previous email, I agree. However, it would be interesting to see what happens if you make an object in the initialiser list consistantly fail on construction-initialisation. Then when the exception is caught in the catch block, construct the object again. A recursive construction-failure scenario as you suggest. If the compiler is clever enough it should report this as a warning. I guess it can not report this as an error as it doesn't stop you from programming recursive functions in general, and you could forget the base test in one of these and hang your program. I may try this out this weekend. When you say 'continue below the catch block' I guess this is a typo and you mean within the catch block. I don't think you can have another block under the catch block as this would be outside the scope of the constructor. Michael ----- Original Message ----- From: Ioannis Vranos <no...@ya...> To: Dev-C++ <dev...@li...> Sent: Wednesday, September 05, 2001 8:08 PM Subject: RE: [Dev-C++] C++ question > -----Original Message----- > From: Michael Codadeen [mailto:jd...@ho...] > Sent: Wednesday, September 05, 2001 5:50 PM > To: no...@ya... > Subject: RE: [Dev-C++] C++ question > > > The standard states at that the function body ends at the end > of the first > block. In effect it looks like a try block but isn't one. > > I think for this specification there isn't a try block. Do you agree ? > > Michael The try block is the function body and the opposite. The problem is, the catch block belongs to where. For instance can we recall the constructor again from the catch block or we can continue below the catch block (that is, it belongs to the constructor too). Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.f2s.com * Alternative URL: http://run.to/noicys _______________________________________________ Dev-cpp-users mailing list Dev...@li... https://lists.sourceforge.net/lists/listinfo/dev-cpp-users |
From: Michael C <jd...@ho...> - 2001-09-05 21:33:34
|
O.K. for argument sake I agree with you. I agree that the catch block is the end of the constructor only when it is present. What I would like to know is what happens when you have an initialiser list of two or more objects that you want to place a try against. Would you have the following ? X () try : a(1), b(2), c(3) { ... } How would you determine in the catch who threw the exception ? I guess each object could throw a different kind of exception and there could be a catch for each kind. But if they all throw the same kind of exception I guess you would need some sort of identification in that exception to correlate it to the offending object. As I am using an older compiler, HPUX 10.20, I cannot play with this myself. When I move to HPUX 11, I'll be able to try it out. Have you tried the above ? Michael ----- Original Message ----- From: Ioannis Vranos <no...@ya...> To: Dev-C++ <dev...@li...> Sent: Wednesday, September 05, 2001 8:18 PM Subject: RE: [Dev-C++] C++ question > -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf > Of Michael Codadeen > Sent: Wednesday, September 05, 2001 6:31 PM > To: no...@ya...; dev...@li... > Subject: RE: [Dev-C++] C++ question > > > I'm not sure if you got my reply so I'll send it again. > > The standard states the the first block following the try is > the function > block. From that I take it that the constructors body ends > there. However, > the catch is associated and is also deemed part of the > constructor, and can > be deemed part of the constructors body. > > Also, the try in this specification has no try-block. > > Conclusion, I would argue that the last brace of the first > block is the end > of the constructors body as you do not necessarily need the > catch block. > > What do you think ? > > Michael I experimented with Dev-C++ and i concluded that the catch block belongs to the constructor too. The constructor ends at the end of the catch block. I guess case is closed... The code: #include <iostream> class Exception {}; class Vector { int size; public: Vector(int s):size(s) {} }; class X { Vector v; public: X(int); }; X::X(int s) try :v(s) { std::cout<<"code run!\n"; throw Exception(); } catch(Exception) { std::cout<<"Exception caught!\n"; std::cout<<s; this; } int main() { X a(7); } _______________________________________________ Dev-cpp-users mailing list Dev...@li... https://lists.sourceforge.net/lists/listinfo/dev-cpp-users |
From: Ioannis V. <no...@ya...> - 2001-09-05 18:17:14
|
> -----Original Message----- > From: dev...@li...=20 > [mailto:dev...@li...] On Behalf=20 > Of Michael Codadeen > Sent: Wednesday, September 05, 2001 6:31 PM > To: no...@ya...; dev...@li... > Subject: RE: [Dev-C++] C++ question >=20 >=20 > I'm not sure if you got my reply so I'll send it again. >=20 > The standard states the the first block following the try is=20 > the function=20 > block. From that I take it that the constructors body ends=20 > there. However,=20 > the catch is associated and is also deemed part of the=20 > constructor, and can=20 > be deemed part of the constructors body. >=20 > Also, the try in this specification has no try-block. >=20 > Conclusion, I would argue that the last brace of the first=20 > block is the end=20 > of the constructors body as you do not necessarily need the=20 > catch block. >=20 > What do you think ? >=20 > Michael I experimented with Dev-C++ and i concluded that the catch block belongs to the constructor too. The constructor ends at the end of the catch block. I guess case is closed... The code: #include <iostream> class Exception {}; class Vector { int size; public: Vector(int s):size(s) {} }; class X { Vector v; public: X(int); }; X::X(int s) try :v(s) { std::cout<<"code run!\n"; throw Exception(); } =20 catch(Exception) { std::cout<<"Exception caught!\n"; std::cout<<s; this; } =20 =20 int main() { X a(7); } |
From: Ioannis V. <no...@ya...> - 2001-09-05 18:06:50
|
> -----Original Message----- > From: Michael Codadeen [mailto:jd...@ho...]=20 > Sent: Wednesday, September 05, 2001 5:50 PM > To: no...@ya... > Subject: RE: [Dev-C++] C++ question >=20 >=20 > The standard states at that the function body ends at the end=20 > of the first=20 > block. In effect it looks like a try block but isn't one. >=20 > I think for this specification there isn't a try block. Do you agree ? >=20 > Michael The try block is the function body and the opposite. The problem is, the catch block belongs to where. For instance can we recall the constructor again from the catch block or we can continue below the catch block (that is, it belongs to the constructor too). Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.f2s.com * Alternative URL: http://run.to/noicys =20 |
From: Michael C. <jd...@ho...> - 2001-09-05 16:31:25
|
I'm not sure if you got my reply so I'll send it again. The standard states the the first block following the try is the function block. From that I take it that the constructors body ends there. However, the catch is associated and is also deemed part of the constructor, and can be deemed part of the constructors body. Also, the try in this specification has no try-block. Conclusion, I would argue that the last brace of the first block is the end of the constructors body as you do not necessarily need the catch block. What do you think ? Michael >From: "Ioannis Vranos" <no...@ya...> >To: "Dev-C++" <dev...@li...> >Subject: RE: [Dev-C++] C++ question >Date: Wed, 5 Sep 2001 17:14:46 +0200 > >I know all that. My question was if tthe body of the constructor ended >at the end of the catch() block or at the end of the try block. I assume >the end of catch() block so far. > > > > >Warm regards, >Ioannis > >* Ioannis Vranos >* Programming pages: http://www.noicys.f2s.com >* Alternative URL: http://run.to/noicys > > > > -----Original Message----- > > From: Michael Codadeen [mailto:jd...@ho...] > > Sent: Wednesday, September 05, 2001 9:59 AM > > To: no...@ya...; dev...@li... > > Subject: Re: [Dev-C++] C++ question > > > > > > Hi, > > > > I've just been speaking to some grus and they tell me this is > > a new feature > > in the standards to catch exceptions in constructors. > > > > Before constructors are invoked the variables of the class > > are initialised. > > If any throw an exception they are not caught. With this new method > > exceptions are caught. > > > > This is not entirely true as you can have pointers > > initialised to 0, and > > then within the braces have a try/catch to assign something to them. > > However, this feature is to be used with the initialiser list. > > > > I suppose this aids 'resource allocation is initialisation' > > that Strousroup > > talks about (i.e. auto pointers). As you know, in this case > > resources are > > able to be freed if a class constructor throws an exception > > on construction > > and doesn't catch it. > > > > Hope this helps, > > > > Michael > > > > > > >From: "Ioannis Vranos" <no...@ya...> > > >To: "Dev-C++" <dev...@li...> > > >Subject: [Dev-C++] C++ question > > >Date: Wed, 5 Sep 2001 06:24:36 +0200 > > > > > >If anyone knows, please answer. > > > > > >The question is about exception handling caught by a > > constructor. Here > > >is the code: > > > > > >class X > > >{ > > >Vector v; > > >// ... > > > > > >public: > > >X(int); > > >// ... > > >}; > > > > > >X::X(int s) try :v(s) // initialize v by s > > >{ > > >// ... > > >} > > > > > >catch(Vector::Size) > > >{ > > >// exceptions thrown for v are caught here > > > > > >//... > > >} > > > > > >------------------------------------------------------------- > > ---------- > > >- > > >-------------------------------------------- > > > > > >This is from the bible. The question here is, the constructor's body > > >ends at the end of catch body? if not, catch() belongs to where. > > > > > >This style compiles only for constructors defined outside of their > > >class. For the non-believers code that compiles: > > > > > >#include <iostream> > > > > > >class Exception {}; > > > > > >class Vector > > >{ > > >int size; > > >public: > > >Vector(int s):size(s) {} > > >}; > > > > > >class X > > >{ > > >Vector v; > > >public: > > >X(int); > > > > > >}; > > > > > >X::X(int s) try :v(s) > > >{ > > >std::cout<<"code run!\n"; > > > > > >throw Exception(); > > > > > >} > > > > > > catch(Exception) > > > { > > > std::cout<<"Exception caught!\n"; > > > > > > > > > } > > > > > > > > >int main() > > >{ > > >X a(7); > > >} > > > > > >------------------------------------------------------------- > > ---------- > > >- > > >-------------------------------------------- > > > > > > > > > > > >Regards, > > >Ioannis > > > > > >* Ioannis Vranos > > >* Programming pages: http://www.noicys.f2s.com > > ><http://www.noicys.f2s.com/> > > >* Alternative URL: http://run.to/noicys > > > > > > > > > _________________________________________________________________ > > Get your FREE download of MSN Explorer at > > http://explorer.msn.com/intl.asp > > > > >_______________________________________________ >Dev-cpp-users mailing list >Dev...@li... >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp |
From: Ioannis V. <no...@ya...> - 2001-09-05 14:13:34
|
I know all that. My question was if tthe body of the constructor ended at the end of the catch() block or at the end of the try block. I assume the end of catch() block so far. Warm regards, 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:59 AM > To: no...@ya...; dev...@li... > Subject: Re: [Dev-C++] C++ question >=20 >=20 > Hi, >=20 > I've just been speaking to some grus and they tell me this is=20 > a new feature=20 > in the standards to catch exceptions in constructors. >=20 > Before constructors are invoked the variables of the class=20 > are initialised.=20 > If any throw an exception they are not caught. With this new method=20 > exceptions are caught. >=20 > This is not entirely true as you can have pointers=20 > initialised to 0, and=20 > then within the braces have a try/catch to assign something to them.=20 > However, this feature is to be used with the initialiser list. >=20 > I suppose this aids 'resource allocation is initialisation'=20 > that Strousroup=20 > talks about (i.e. auto pointers). As you know, in this case=20 > resources are=20 > able to be freed if a class constructor throws an exception=20 > on construction=20 > and doesn't catch it. >=20 > Hope this helps, >=20 > Michael >=20 >=20 > >From: "Ioannis Vranos" <no...@ya...> > >To: "Dev-C++" <dev...@li...> > >Subject: [Dev-C++] C++ question > >Date: Wed, 5 Sep 2001 06:24:36 +0200 > > > >If anyone knows, please answer. > > > >The question is about exception handling caught by a=20 > constructor. Here=20 > >is the code: > > > >class X > >{ > >Vector v; > >// ... > > > >public: > >X(int); > >// ... > >}; > > > >X::X(int s) try :v(s) // initialize v by s > >{ > >// ... > >} > > > >catch(Vector::Size) > >{ > >// exceptions thrown for v are caught here > > > >//... > >} > > > >------------------------------------------------------------- > ---------- > >- > >-------------------------------------------- > > > >This is from the bible. The question here is, the constructor's body=20 > >ends at the end of catch body? if not, catch() belongs to where. > > > >This style compiles only for constructors defined outside of their=20 > >class. For the non-believers code that compiles: > > > >#include <iostream> > > > >class Exception {}; > > > >class Vector > >{ > >int size; > >public: > >Vector(int s):size(s) {} > >}; > > > >class X > >{ > >Vector v; > >public: > >X(int); > > > >}; > > > >X::X(int s) try :v(s) > >{ > >std::cout<<"code run!\n"; > > > >throw Exception(); > > > >} > > > > catch(Exception) > > { > > std::cout<<"Exception caught!\n"; > > > > > > } > > > > > >int main() > >{ > >X a(7); > >} > > > >------------------------------------------------------------- > ---------- > >- > >-------------------------------------------- > > > > > > > >Regards, > >Ioannis > > > >* Ioannis Vranos > >* Programming pages: http://www.noicys.f2s.com=20 > ><http://www.noicys.f2s.com/> > >* Alternative URL: http://run.to/noicys > > >=20 >=20 > _________________________________________________________________ > Get your FREE download of MSN Explorer at=20 > http://explorer.msn.com/intl.asp >=20 |
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; > } |
From: Michael C. <jd...@ho...> - 2001-09-05 08:22:19
|
Sorry, select 15 : Exception Handling Point 3 has a good example. The { } after the try :v(s) is the function body. >From: "Michael Codadeen" <jd...@ho...> >To: no...@ya..., dev...@li... >Subject: Re: [Dev-C++] C++ question >Date: Wed, 05 Sep 2001 08:14:39 +0000 > >Hi > >Look at : > >http://anubis.dkuug.dk/jtc1/sc22/open/n2356/ > >example 3. > >Michael > >>From: "Ioannis Vranos" <no...@ya...> >>To: "Dev-C++" <dev...@li...> >>Subject: [Dev-C++] C++ question >>Date: Wed, 5 Sep 2001 06:24:36 +0200 >> >>If anyone knows, please answer. >> >>The question is about exception handling caught by a constructor. Here >>is the code: >> >>class X >>{ >>Vector v; >>// ... >> >>public: >>X(int); >>// ... >>}; >> >>X::X(int s) try :v(s) // initialize v by s >>{ >>// ... >>} >> >>catch(Vector::Size) >>{ >>// exceptions thrown for v are caught here >> >>//... >>} >> >>------------------------------------------------------------------------ >>-------------------------------------------- >> >>This is from the bible. The question here is, the constructor's body >>ends at the end of catch body? if not, catch() belongs to where. >> >>This style compiles only for constructors defined outside of their >>class. For the non-believers code that compiles: >> >>#include <iostream> >> >>class Exception {}; >> >>class Vector >>{ >>int size; >>public: >>Vector(int s):size(s) {} >>}; >> >>class X >>{ >>Vector v; >>public: >>X(int); >> >>}; >> >>X::X(int s) try :v(s) >>{ >>std::cout<<"code run!\n"; >> >>throw Exception(); >> >>} >> >> catch(Exception) >> { >> std::cout<<"Exception caught!\n"; >> >> >> } >> >> >>int main() >>{ >>X a(7); >>} >> >>------------------------------------------------------------------------ >>-------------------------------------------- >> >> >> >>Regards, >>Ioannis >> >>* Ioannis Vranos >>* Programming pages: http://www.noicys.f2s.com >><http://www.noicys.f2s.com/> >>* Alternative URL: http://run.to/noicys >> > > >_________________________________________________________________ >Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp > > >_______________________________________________ >Dev-cpp-users mailing list >Dev...@li... >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp |
From: Michael C. <jd...@ho...> - 2001-09-05 08:14:46
|
Hi Look at : http://anubis.dkuug.dk/jtc1/sc22/open/n2356/ example 3. Michael >From: "Ioannis Vranos" <no...@ya...> >To: "Dev-C++" <dev...@li...> >Subject: [Dev-C++] C++ question >Date: Wed, 5 Sep 2001 06:24:36 +0200 > >If anyone knows, please answer. > >The question is about exception handling caught by a constructor. Here >is the code: > >class X >{ >Vector v; >// ... > >public: >X(int); >// ... >}; > >X::X(int s) try :v(s) // initialize v by s >{ >// ... >} > >catch(Vector::Size) >{ >// exceptions thrown for v are caught here > >//... >} > >------------------------------------------------------------------------ >-------------------------------------------- > >This is from the bible. The question here is, the constructor's body >ends at the end of catch body? if not, catch() belongs to where. > >This style compiles only for constructors defined outside of their >class. For the non-believers code that compiles: > >#include <iostream> > >class Exception {}; > >class Vector >{ >int size; >public: >Vector(int s):size(s) {} >}; > >class X >{ >Vector v; >public: >X(int); > >}; > >X::X(int s) try :v(s) >{ >std::cout<<"code run!\n"; > >throw Exception(); > >} > > catch(Exception) > { > std::cout<<"Exception caught!\n"; > > > } > > >int main() >{ >X a(7); >} > >------------------------------------------------------------------------ >-------------------------------------------- > > > >Regards, >Ioannis > >* Ioannis Vranos >* Programming pages: http://www.noicys.f2s.com ><http://www.noicys.f2s.com/> >* Alternative URL: http://run.to/noicys > _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp |
From: Michael C. <jd...@ho...> - 2001-09-05 07:59:07
|
Hi, I've just been speaking to some grus and they tell me this is a new feature in the standards to catch exceptions in constructors. Before constructors are invoked the variables of the class are initialised. If any throw an exception they are not caught. With this new method exceptions are caught. This is not entirely true as you can have pointers initialised to 0, and then within the braces have a try/catch to assign something to them. However, this feature is to be used with the initialiser list. I suppose this aids 'resource allocation is initialisation' that Strousroup talks about (i.e. auto pointers). As you know, in this case resources are able to be freed if a class constructor throws an exception on construction and doesn't catch it. Hope this helps, Michael >From: "Ioannis Vranos" <no...@ya...> >To: "Dev-C++" <dev...@li...> >Subject: [Dev-C++] C++ question >Date: Wed, 5 Sep 2001 06:24:36 +0200 > >If anyone knows, please answer. > >The question is about exception handling caught by a constructor. Here >is the code: > >class X >{ >Vector v; >// ... > >public: >X(int); >// ... >}; > >X::X(int s) try :v(s) // initialize v by s >{ >// ... >} > >catch(Vector::Size) >{ >// exceptions thrown for v are caught here > >//... >} > >------------------------------------------------------------------------ >-------------------------------------------- > >This is from the bible. The question here is, the constructor's body >ends at the end of catch body? if not, catch() belongs to where. > >This style compiles only for constructors defined outside of their >class. For the non-believers code that compiles: > >#include <iostream> > >class Exception {}; > >class Vector >{ >int size; >public: >Vector(int s):size(s) {} >}; > >class X >{ >Vector v; >public: >X(int); > >}; > >X::X(int s) try :v(s) >{ >std::cout<<"code run!\n"; > >throw Exception(); > >} > > catch(Exception) > { > std::cout<<"Exception caught!\n"; > > > } > > >int main() >{ >X a(7); >} > >------------------------------------------------------------------------ >-------------------------------------------- > > > >Regards, >Ioannis > >* Ioannis Vranos >* Programming pages: http://www.noicys.f2s.com ><http://www.noicys.f2s.com/> >* Alternative URL: http://run.to/noicys > _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp |
From: Michael C. <jd...@ho...> - 2001-09-05 07:34:41
|
Hi, I have just tried this on the HPUX 10.20 aCC compiler and it does not compile. The 'try' breaks it. Enclosing the try/catch block within braces does compile. Out of interest which page of Stroustroups book is this on ? Regards, Michael --- Here is the compiled code for the HPUX... #include <iostream.h> class Exception {}; class Vector { int size; public: Vector(int s):size(s) {} }; class X { Vector v; public: X(int); }; X::X(int s) :v(s) { try { cout <<"code run!\n"; throw Exception(); } catch(Exception) { cout <<"Exception caught!\n"; } } int main() { X x(3); return 0; } ----- >From: "Ioannis Vranos" <no...@ya...> >To: "Dev-C++" <dev...@li...> >Subject: [Dev-C++] C++ question >Date: Wed, 5 Sep 2001 06:24:36 +0200 > >If anyone knows, please answer. > >The question is about exception handling caught by a constructor. Here >is the code: > >class X >{ >Vector v; >// ... > >public: >X(int); >// ... >}; > >X::X(int s) try :v(s) // initialize v by s >{ >// ... >} > >catch(Vector::Size) >{ >// exceptions thrown for v are caught here > >//... >} > >------------------------------------------------------------------------ >-------------------------------------------- > >This is from the bible. The question here is, the constructor's body >ends at the end of catch body? if not, catch() belongs to where. > >This style compiles only for constructors defined outside of their >class. For the non-believers code that compiles: > >#include <iostream> > >class Exception {}; > >class Vector >{ >int size; >public: >Vector(int s):size(s) {} >}; > >class X >{ >Vector v; >public: >X(int); > >}; > >X::X(int s) try :v(s) >{ >std::cout<<"code run!\n"; > >throw Exception(); > >} > > catch(Exception) > { > std::cout<<"Exception caught!\n"; > > > } > > >int main() >{ >X a(7); >} > >------------------------------------------------------------------------ >-------------------------------------------- > > > >Regards, >Ioannis > >* Ioannis Vranos >* Programming pages: http://www.noicys.f2s.com ><http://www.noicys.f2s.com/> >* Alternative URL: http://run.to/noicys > _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp |
From: Shin T. <ta...@mu...> - 2001-09-05 04:36:32
|
help I couldn't find the Toolbar97 directory in the source archive. According to the VCL.txt, there should be the directory, "vcl\toolbar97", and the file "TB97_D5.dpk" at least, but neither such directory nor file was included in the source archives I had downloaded from bloodshed and sourceforge. Could you please advise where I could get these required files ? Here's the comments in the VCL.txt. > To install them, launch and install devcpp.dpk. Then install SynEdit > components by using the package SynEdit\SynEdit_D5.dpk. Finish by > installing ToolBar97 by installing package ToolBar97\TB97_D5.dpk > - ToolBar97: great components for using toolbars. > Located in Vcl\Toolbar97\ > Author: Jose Sebastian Battig, Softech Regards, Shin Takano |
From: Ioannis V. <no...@ya...> - 2001-09-05 03:23:23
|
If anyone knows, please answer. =20 The question is about exception handling caught by a constructor. Here is the code: =20 class X { Vector v; // ... =20 public: X(int); // ... }; =20 X::X(int s) try :v(s) // initialize v by s { // ... } =20 catch(Vector::Size) { // exceptions thrown for v are caught here =20 //... } =20 ------------------------------------------------------------------------ -------------------------------------------- =20 This is from the bible. The question here is, the constructor's body ends at the end of catch body? if not, catch() belongs to where. =20 This style compiles only for constructors defined outside of their class. For the non-believers code that compiles: =20 #include <iostream> =20 class Exception {}; =20 class Vector { int size; public: Vector(int s):size(s) {} }; =20 class X { Vector v; public: X(int); =20 }; =20 X::X(int s) try :v(s) { std::cout<<"code run!\n"; =20 throw Exception(); =20 } =20 catch(Exception) { std::cout<<"Exception caught!\n"; =20 =20 } =20 int main() { X a(7); } =20 ------------------------------------------------------------------------ -------------------------------------------- =20 =20 =20 Regards, Ioannis =20 * Ioannis Vranos * Programming pages: http://www.noicys.f2s.com <http://www.noicys.f2s.com/>=20 * Alternative URL: http://run.to/noicys =20 |